Network/CommunityStructure.pm

filter: Statementstmt 72.7% 16 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 100% 3 / 3 totaltotal 75.0% 24 / 32 CC 1 SCAR 2.5
CC
1
Cov
73%
communities
2.0
modularity
2.0
BEGIN
1.0
CRAP 1.3
« Network.pm ↑ Summary Network/Node/Plugin/Test.pm »
1 package SNA::Network::CommunityStructure;
2  
3 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 15 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 15 ▶use List::Util qw(sum);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 =head1 NAME
11  
12 SNA::Network::CommunityStructure - Community structure class for SNA::Network
13  
14  
15 =head1 SYNOPSIS
16  
17 $n->identify_communities_with_louvain
18
19 # output the number of hierarchical levels
20 say int @{$n->community_levels}
21
22 # print the number of communities on the first, finest-granular level
23 say int $n->community_levels->[0]->communities
24
25 # print the modularity of the first-level structure
26 say int $n->community_levels->[0]->modularity
27  
28
29
30  
31 =head1 METHODS
32  
33 =head2 new
34  
35 Creates a new community structure with a passed list of L<SNA::Network::Community> objects.
36  
37 =cut
38  
39 2 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
40 2 my ($package, @communities) = @_;
41 2 my $self = bless [ @communities ], $package;
42 2 return $self;
43 }
44  
45  
46 =head2 communities
47  
48 Returns a list of L<SNA::Network::Community> objects, which are part of this structure.
49  
50 =cut
51  
52 0 ▶sub communities {
Subroutine communities: not called CC=1 SCAR=6.9
Pod documented
53 0 my ($self) = @_;
54 0 return @{ $self };
55 }
56  
57  
58 =head2 modularity
59  
60 Returns the network modularity value of this community structure
61  
62 =cut
63  
64 0 ▶sub modularity {
Subroutine modularity: not called CC=1 SCAR=6.9
Pod documented
65 0 my ($self) = @_;
66 0 return sum map { $_->module_value } @$self;
67 }
68  
69  
70  
71 =head1 AUTHOR
72  
73 Darko Obradovic, C<< <dobradovic at gmx.de> >>
74  
75 =head1 BUGS
76  
77 Please report any bugs or feature requests to C<bug-sna-network-node at rt.cpan.org>, or through
78 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SNA-Network>. I will be notified, and then you'll
79 automatically be notified of progress on your bug as I make changes.
80  
81  
82  
83  
84 =head1 SUPPORT
85  
86 You can find documentation for this module with the perldoc command.
87  
88 perldoc SNA::Network
89  
90  
91 You can also look for information at:
92  
93 =over 4
94  
95 =item * RT: CPAN's request tracker
96  
97 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=SNA-Network>
98  
99 =item * AnnoCPAN: Annotated CPAN documentation
100  
101 L<http://annocpan.org/dist/SNA-Network>
102  
103 =item * CPAN Ratings
104  
105 L<http://cpanratings.perl.org/d/SNA-Network>
106  
107 =item * Search CPAN
108  
109 L<http://search.cpan.org/dist/SNA-Network>
110  
111 =back
112  
113  
114 =head1 ACKNOWLEDGEMENTS
115  
116  
117 =head1 COPYRIGHT & LICENSE
118  
119 Copyright 2014 Darko Obradovic, all rights reserved.
120  
121 This program is free software; you can redistribute it and/or modify it
122 under the same terms as Perl itself.
123  
124  
125 =cut
126  
127 15 1;
128  
« Network.pm ↑ Summary Network/Node/Plugin/Test.pm »