blib/lib/SNA/Network/Community.pm

filter: Statementstmt 100% 28 / 28 Branchbran 50.0% 3 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 93.3% 42 / 45 CC 4 SCAR 7.8
CC
4
Cov
91%
new
4.2
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« blib/lib/SNA/Network/Algorithm/Connectivity.pm ↑ Summary blib/lib/SNA/Network/Algorithm/HITS.pm »
1 package SNA::Network::Community;
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 15 ▶use Object::Tiny::XS qw(network members_ref index w_in w_tot);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12 =head1 NAME
13  
14 SNA::Network::Community - Community class for SNA::Network
15  
16  
17 =head1 SYNOPSIS
18  
19 foreach my $community ($net->communities) {
20 print int $community->members;
21 ...
22 }
23 ...
24 ...
25  
26  
27 =head1 METHODS
28  
29 =head2 new
30  
31 Creates a new community with the given named parameters.
32 Not intended for external use.
33  
34 =cut
35  
36 sub new {
37 190 ▶ my ($package, %params) = @_;
Subroutine new: called CC=4 SCAR=14.5
Pod documented
38 190 ▶ croak 'no network passed' unless $params{network};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"network"} 0 190 190
39 190 ▶ croak 'no index passed' unless defined $params{index};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $params{"index"} 0 190 190
40 190 ▶ croak 'no members_ref passed' unless $params{members_ref};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"members_ref"} 0 190 190
41 190 my $self = bless { %params }, $package;
42 190 return $self;
43 }
44  
45  
46 =head2 network
47  
48 Returns the reference of the L<SNA::Network> object this community belongs to.
49  
50  
51 =head2 index
52  
53 Returns the index number of this community.
54 All communities are sequentially numbered starting with 0.
55  
56  
57 =head2 members
58  
59 Returns a list of L<SNA::Network::Node> objects, which are members of this community.
60  
61 =cut
62  
63 sub members {
64 491 ▶ my ($self) = @_;
Subroutine members: called CC=1 SCAR=0.0
Pod documented
65 491 return @{ $self->members_ref };
66 }
67  
68  
69 =head2 members_ref
70  
71 Returns the reference to the list of L<SNA::Network::Node> objects, which are members of this community.
72  
73  
74 =head2 w_in
75  
76 Returns the sum of all edge weights between community nodes
77  
78  
79 =head2 w_tot
80  
81 Returns the sum of all community node's summed degrees.
82  
83  
84 =head2 module_value
85  
86 Returns the module value of this community
87  
88 =cut
89  
90 sub module_value {
91 8 ▶ my ($self) = @_;
Subroutine module_value: called CC=1 SCAR=0.0
Pod documented
92 8 my $net_weight = $self->network->{total_weight};
93 8 return $self->w_in / $net_weight - ( ( $self->w_in + $self->w_tot ) / ( 2 * $net_weight ) ) ** 2;
94 }
95  
96  
97  
98 =head1 AUTHOR
99  
100 Darko Obradovic, C<< <dobradovic at gmx.de> >>
101  
102 =head1 BUGS
103  
104 Please report any bugs or feature requests to C<bug-sna-network-node at rt.cpan.org>, or through
105 the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SNA-Network>. I will be notified, and then you'll
106 automatically be notified of progress on your bug as I make changes.
107  
108  
109  
110  
111 =head1 SUPPORT
112  
113 You can find documentation for this module with the perldoc command.
114  
115 perldoc SNA::Network
116  
117  
118 You can also look for information at:
119  
120 =over 4
121  
122 =item * RT: CPAN's request tracker
123  
124 L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=SNA-Network>
125  
126 =item * AnnoCPAN: Annotated CPAN documentation
127  
128 L<http://annocpan.org/dist/SNA-Network>
129  
130 =item * CPAN Ratings
131  
132 L<http://cpanratings.perl.org/d/SNA-Network>
133  
134 =item * Search CPAN
135  
136 L<http://search.cpan.org/dist/SNA-Network>
137  
138 =back
139  
140  
141 =head1 ACKNOWLEDGEMENTS
142  
143  
144 =head1 COPYRIGHT & LICENSE
145  
146 Copyright 2012 Darko Obradovic, all rights reserved.
147  
148 This program is free software; you can redistribute it and/or modify it
149 under the same terms as Perl itself.
150  
151  
152 =cut
153  
154 15 1;
155  
« blib/lib/SNA/Network/Algorithm/Connectivity.pm ↑ Summary blib/lib/SNA/Network/Algorithm/HITS.pm »