BiStar.pm

filter: Statementstmt 75.0% 6 / 8 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 81.8% 9 / 11 CC 1 SCAR 0.9
CC
1
Cov
75%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« MostMaximumMatchingsTree.pm ↑ Summary BinomialTree.pm »
1 # Copyright 2017, 2018, 2019, 2020, 2021 Kevin Ryde
2 #
3 # This file is part of Graph-Maker-Other.
4 #
5 # This file is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the Free
7 # Software Foundation; either version 3, or (at your option) any later
8 # version.
9 #
10 # This file is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with Graph-Maker-Other. See the file COPYING. If not, see
17 # <http://www.gnu.org/licenses/>.
18  
19  
20 package Graph::Maker::BiStar;
21 1 ▶use 5.004;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Graph::Maker;
Subroutine BEGIN: called CC=1 SCAR=2.6
24  
25 use vars '$VERSION','@ISA';
26 $VERSION = 17;
27 @ISA = ('Graph::Maker');
28  
29  
30 sub _default_graph_maker {
31 require Graph;
32 return Graph->new(@_);
33 }
34 sub _make_graph {
35 my ($params) = @_;
36 my $graph_maker = delete($params->{'graph_maker'}) || \&_default_graph_maker;
37 return $graph_maker->(%$params);
38 }
39  
40 sub init {
41 my ($self, %params) = @_;
42 my $N = delete($params{'N'}) || 0;
43 my $M = delete($params{'M'}) || 0;
44  
45 my $graph = _make_graph(\%params);
46 $graph->set_graph_attribute (name => "Bi-Star $N,$M");
47 my $add_edge = ($graph->is_directed ? 'add_cycle' : 'add_edge');
48 my $from = 1;
49 foreach my $size ($N, $M) {
50 next unless $size;
51 $graph->add_vertex($from);
52 foreach my $add (1 .. $size-1) {
53 $graph->$add_edge($from, $from+$add);
54 }
55 $from += $size;
56 }
57 if ($N && $M) {
58 $graph->$add_edge (1, 1+$N);
59 }
60 return $graph;
61 }
62  
63 Graph::Maker->add_factory_type('bi_star' => __PACKAGE__);
64 1;
65  
66 __END__
« MostMaximumMatchingsTree.pm ↑ Summary BinomialTree.pm »