line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SNA::Network::CommunityStructure; |
2
|
|
|
|
|
|
|
|
3
|
14
|
|
|
14
|
|
56
|
use strict; |
|
14
|
|
|
|
|
20
|
|
|
14
|
|
|
|
|
465
|
|
4
|
14
|
|
|
14
|
|
61
|
use warnings; |
|
14
|
|
|
|
|
18
|
|
|
14
|
|
|
|
|
303
|
|
5
|
|
|
|
|
|
|
|
6
|
14
|
|
|
14
|
|
54
|
use Carp; |
|
14
|
|
|
|
|
17
|
|
|
14
|
|
|
|
|
722
|
|
7
|
14
|
|
|
14
|
|
58
|
use List::Util qw(sum); |
|
14
|
|
|
|
|
19
|
|
|
14
|
|
|
|
|
2427
|
|
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 objects. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub new { |
40
|
2
|
|
|
2
|
1
|
4
|
my ($package, @communities) = @_; |
41
|
2
|
|
|
|
|
5
|
my $self = bless [ @communities ], $package; |
42
|
2
|
|
|
|
|
8
|
return $self; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 communities |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Returns a list of L objects, which are part of this structure. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub communities { |
53
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
54
|
0
|
|
|
|
|
|
return @{ $self }; |
|
0
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 modularity |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Returns the network modularity value of this community structure |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub modularity { |
65
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
66
|
0
|
|
|
|
|
|
return sum map { $_->module_value } @$self; |
|
0
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 AUTHOR |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Darko Obradovic, C<< >> |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 BUGS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
78
|
|
|
|
|
|
|
the web interface at L. 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 |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
L |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item * CPAN Ratings |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
L |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item * Search CPAN |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
L |
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
|
|
|
|
|
|
|
1; |
128
|
|
|
|
|
|
|
|