Branch Coverage

blib/lib/Graph.pm
Criterion Covered Total %
branch 624 722 86.4


line true false branch
5 0 80 if $ENV{'GRAPH_ALLOW_RECURSION'}
30 16 4 if defined $can_deep_copy_Storable
31 0 4 if $] < "5.01"
51 80 0 if ($] >= 5.022) { }
57 0 0 unless eval { do { $Inf = "Inf" } } or eval { do { $Inf = "Inf" } } or eval { do { $Inf = "Inf" } }
86 326 299 $u ? :
89 4 1302 $h ? :
3140 1306 $u ? :
117 591 7482 if delete $opt->{$flag}
118 0 8073 if delete $$opt{"non$flag"}
124 5 1 unless exists $opt->{$key}
130 1222 6 unless my(@opt) = keys %$opt
131 1 5 @opt > 1 ? :
140 0 106 if $g->has_union_find
158 274 623 if exists $opt->{'directed'}
172 106 791 if ref $class and $class->isa("Graph")
183 95 802 if ($opt{'vertices'})
185 0 95 if ref $opt{'vertices'} ne "ARRAY"
190 23 874 if ($opt{'edges'})
192 0 23 if ref $opt{'edges'} ne "ARRAY"
198 1 893 if $vflags & 1 and $vflags & 2
201 1 892 if $eflags & 1 and $eflags & 2
211 76 816 if @V
213 0 892 if grep((ref $_ ne "ARRAY"), @E)
217 5 887 if $gflags & 16
225 105 787 $vflags ? :
230 12 46 $is_hyper ? :
58 834 $is_hyper || $eflags & 18446744073709551611 ? :
272 5 2096 if @_ != 2
273 1 2095 if grep((!defined($_)), @_)
280 534 2125 if $V->[1] & 8
292 1139 14 unless &is_multivertexed or &is_countvertexed
293 2 12 if wantarray
307 11 15544 if @_ != 3
320 56 0 @i ? :
332 267 18 @i ? :
338 0 38189 if grep((!defined($_)), @args)
341 344 37845 if $V->[1] & 8 or $deep
344 1302 36543 if not $ensure and @non_exist
345 36 36507 if @non_exist
353 4 19977 if $Ea and @_ != $Ea + 1
356 1420 18557 if (my(@i) = &_vertex_ids) != @_ - 1
357 11 0 $directed ? :
11 18546 if $deep
358 15139 3407 unless $directed
366 6 16 if (my(@i) = $V->get_ids_by_paths(\@args)) != @args
373 55 1181 unless wantarray
382 339 28 unless &is_multiedged or &is_countedged
383 14 14 if wantarray
401 1 12 if $V->has_path_by_multi_id(my(@args) = ($v, $id))
403 0 12 if &has_union_find
412 0 6 if &has_union_find
427 1 2 unless &has_vertex_by_id
446 14 42 if &is_undirected
449 2 54 if &has_union_find
457 6 7 if &is_undirected
460 0 13 if &has_union_find
468 18 134 if @i < @_ - 2
470 11 123 if &is_undirected
480 0 4 if @i < @_ - 2
482 0 4 if &is_undirected
483 1 3 unless $E->has_path_by_multi_id(my(@args) = (\@i, $id))
491 0 34 unless @_ - 1 == (my(@i) = &_vertex_ids)
500 79 110 if &is_undirected
502 109 1 wantarray ? :
508 4 472 if (my(@i) = $V->get_ids_by_paths(\@args, &is_hyperedged && &is_directed)) != @args
513 0 326 if &is_undirected
516 3 323 if (my(@i) = $V->get_ids_by_paths(\@args, &is_hyperedged && &is_directed)) != @args
521 1 11 unless wantarray
526 0 287 unless wantarray
531 30 216 if &is_undirected
532 0 216 unless wantarray
539 6 8084 if (my(@i) = $V->get_ids_by_paths(\@args)) != @args
541 4095 3989 unless wantarray
546 3459 1604 if &is_undirected
549 4 1600 if (my(@i) = $V->get_ids_by_paths(\@args)) != @args
551 1403 197 unless wantarray
560 80 86 if $self_only_if_loop
565 124 211 if $next->is_null
569 80 86 if $self_only_if_loop
570 160 6 wantarray ? :
606 82 137 if &is_directed
607 207 12 wantarray ? :
618 18 18 &directed ? :
622 9 8 &directed ? :
628 5 462 if (my(@i) = &_vertex_ids) != @_ - 1
629 12 450 if &is_undirected
630 9 453 unless @i and $g->[3]->del_path(\@i)
638 1 183 if @_ != 2
640 6 177 unless defined $V->has_path($_[1])
656 16 959 if (my(@i) = &_vertex_ids) != @_ - 1
657 78 881 if &is_undirected
687 0 232 unless @_ > 1 and &has_vertex
690 5 227 if &is_undirected and &is_self_loop_vertex
696 0 208 unless @_ > 1 and &has_vertex
699 1 207 if &is_undirected and &is_self_loop_vertex
704 0 42 unless @_ > 1 and &has_vertex
705 24 18 &is_undirected ? :
709 36 2 if @_ > 1
710 1 1 if &is_directed
720 0 36 unless @_ > 1
721 10 26 if &successors == 0
725 0 36 unless @_ > 1
726 7 29 if &predecessors == 0
730 0 36 unless @_ > 1
735 0 36 unless @_ > 1
740 0 36 unless @_ > 1
745 0 36 unless @_ > 1
750 0 4694 unless @_ > 1
751 462 4232 if &predecessors == 0
755 0 36 unless @_ > 1
757 8 28 if my $isl = &is_self_loop_vertex
758 13 23 if $s == 0
759 15 8 if &is_undirected
761 2 6 if $isl
766 0 36 unless @_ > 1
767 29 7 unless &predecessors == 0
771 0 108 unless @_ > 1
772 22 86 if grep(($_ eq $_[1]), &successors)
827 13 30 unless $g->has_edge($u, $v)
845 1 8 if @_ == 1
863 1 1 if &is_undirected
869 2 0 $t->has_state('a_cycle') ? :
912 2115 116 unless $is_vertex or $is_undirected or $is_multi
913 14253 129 unless $is_vertex or $is_multi
914 1545 129 if $is_vertex
916 13 116 $is_undirected ? :
924 25 4603 $is_multi ? :
38 4657 $is_multi ? :
4628 67 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
925 4627 68 $entity eq 'edge' ? :
934 10 1015 $is_multi ? :
14 1100 $is_multi ? :
1025 89 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
935 12 1102 $entity eq 'edge' ? :
943 20 20 $is_multi ? :
0 40 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
944 20 20 $entity eq 'edge' ? :
953 12 12 $is_multi ? :
4 20 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
954 10 10 $entity eq 'edge' ? :
962 36 595 $is_multi ? :
2 629 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
963 552 77 $entity eq 'edge' ? :
972 64 11474 $is_multi ? :
38 11500 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
973 11254 246 $entity eq 'edge' ? :
981 6 6 $is_multi ? :
0 12 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
982 6 6 $entity eq 'edge' ? :
990 6 6 $is_multi ? :
0 12 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
991 6 6 $entity eq 'edge' ? :
999 4 4 $is_multi ? :
0 8 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
1000 4 4 $entity eq 'edge' ? :
1009 6 6 $is_multi ? :
0 12 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
1010 6 6 $entity eq 'edge' ? :
1017 2 2266 if (&is_multivertexed)
1023 2261 5 unless &has_union_find
1032 67 1 @args ? :
32498 68 ref $u eq 'ARRAY' ? :
1035 52 17755 if (&is_multiedged)
1041 14 17741 $deep ? :
1042 15334 2421 if &is_undirected
1044 5 17750 if $uf
1067 2 9 if (&is_multivertexed) { }
1083 36 4 unless $g->get_edge_attributes(@$e)
13 40 $multi_e ? :
1085 12 41 if ($is_hyper) { }
1087 8 4 if ($is_directed) { }
1095 15 26 unless $is_directed
1098 4 7 $is_hyper ? :
1104 4 8 if (&is_multivertexed) { }
1110 6 6 if (&is_multiedged) { }
1131 13 259 &$_ ? :
1140 19 0 &_can_deep_copy_Storable() ? :
1160 1 0 if $] >= "5.008"
1167 1 16 if grep ref($_), &_vertices05
1175 0 486 unless &is_directed
1176 0 486 unless &has_edge
1180 413 73 unless $g->has_edge(@e)
1182 0 486 if $a
1188 3 17 unless &directed
1201 12 7 $directed ? :
1220 0 23 unless ref $src eq "ARRAY" and !defined($dst) || ref $dst eq 'ARRAY'
1225 4 19 $dst ? :
1226 4 19 $dst ? :
1228 12 11 if ($directed) { }
1231 2 9 $dst ? :
1456 5 38 @_ ? :
1457 30 13 defined $got ? :
1458 43 0 if (my(@caller2) = caller 2) { }
1468 10 0 unless @_
1474 14 1169 unless &is_undirected
1478 10 251 unless &is_directed
1482 1 2 unless &is_acyclic
1487 2 5 unless &is_directed
1488 3 4 unless &is_acyclic
1489 5 2 if @got
1493 2 9 unless &is_hyperedged
1497 4 222 unless &is_multivertexed
1502 1 1491 if &is_multivertexed
1507 1 19009 if &is_multiedged
1512 4 412 unless &is_multiedged
1517 1 676 if &has_union_find
1522 3 1098 unless (@_ == 1 and ref $_[0] eq "ARRAY")
1526 0 1098 unless (@opt % 2 == 0)
1557 0 80 $^P && $] < 5.009003 ? :
1561 3 11 @_ % 2 == 0 ? :
1564 2 12 unless defined $opt{'vertices'}
1565 4 8 if exists $opt{'random_seed'}
1566 1 11 if exists $opt{'random_edge'}
1568 1 11 if (my $ref = ref $opt{'vertices'}) { }
1569 0 1 if $ref ne "ARRAY"
1580 0 2 if exists $opt{'edges'} and exists $opt{'edges_fill'}
1581 1 11 exists $opt{'edges_fill'} ? :
1586 0 12 if $V < 2
1587 11 1 if my $is_directed = $g->directed
1588 9 3 unless defined $E
1591 3 9 unless defined $random_edge
1593 0 12 if $p > 1 and not $g->countedged || $g->multiedged
1604 275 12573 if $v1 eq $v2
1606 5809 259 $is_directed ? :
6027 41 if ($q and $q == 1 || rand() <= $q and not exists $v1_v2{$v1}{$v2} and $is_directed ? 1 : !exists $v1_v2{$v2}{$v1})
1612 12 6015 unless $E
1650 0 23 exists $attr->{'attribute'} ? :
1653 0 23 exists $attr->{'comparator'} ? :
1679 1152 454 if $UF->same(@$e)
1700 3 147 @args == 1 ? :
1706 1 149 if (exists $opt{'start'})
1710 107 43 if (exists $opt{'first_root'}) { }
1711 1 106 if (ref $opt{'first_root'} eq 'CODE') { }
1725 0 149 $opt{'next_numeric'} ? :
0 149 $opt{'next_alphabetic'} ? :
1 149 exists $opt{'next_root'} ? :
1728 0 150 exists $opt{'attribute'} ? :
1743 4087 0 if (defined $t)
1746 1894 2193 if (exists $unseenh->{$v})
1753 1 103 unless defined $next
1754 103 0 $code ? :
1755 81 22 unless defined $r
1781 2 3 &is_directed && &is_acyclic ? :
1795 1 4 if ($eic) { }
1803 1 1 $hac ? :
1852 0 2283 unless defined $c
1854 0 2283 if @extra_keys != @$extra_vals
1856 0 2283 if defined $a and ref $a ne "ARRAY"
1858 459 1824 unless (defined $a and $a->[0] == $g->[1])
1865 106 0 unless not defined $v
1867 29 2252 if ($extra_invalid)
1881 5 35 unless my(@v) = $g->unique_vertices
1882 9 26 if (my $UF = &has_union_find) { }
1889 0 20 unless defined $cc
1891 13 7 unless exists $cc2counter{$cc}
1903 8 26 if keys %r
1931 0 41 unless $value
41 16 $value ? :
1943 14 14 if (my $UF = &has_union_find) { }
1945 4 10 if @ids != @args
1950 4 20 if grep((!defined($_)), @components)
1961 2 18 if ($g->has_union_find and $g->vertices == 1) { }
2029 14 122 unless defined(my $root = &List::Util::first(sub { exists $u->{$_}; } , @d))
2070 1 4 unless defined(my $c = &_strongly_connected_components->[0][$i])
2111 14931 1924 if $e->[0] eq $u and $e->[1] eq $v
2113 14931 0 if @BC
2120 15948 19372 if (not exists $state->{'num'}{$v}) { }
907 34413 elsif (defined $state->{'pred'}{$u} and $state->{'pred'}{$u} ne $v and $state->{'num'}{$v} < $state->{'num'}{$u}) { }
2126 14931 1017 if $state->{'low'}{$v} >= $state->{'num'}{$u}
2143 15948 1660 if exists $state{'num'}{$u}
2145 3 1657 unless $state{'stack'}
0 1660 if @{&_empty_array() unless $state{'stack'};}
2167 3014 14594 if @components > 1
2181 0 470 unless _check_cache($_[0], "biconnectivity", [], \&Graph::_biconnectivity_compute, @_[1 .. $#_])
2186 10 3 &edges >= 2 ? :
2190 10 3 &edges >= 2 ? :
2194 10 3 &edges >= 2 ? :
2218 2 0 defined $v2bc->{$v} ? :
2225 0 5 if grep((!defined($_)), my(@vecs) = @$v2bc{@vs})
2243 6 4 unless grep exists $j{$_}, @u
2252 0 59 unless (&biconnectivity)[2]
2264 5155 98 unless defined $t
2265 1 5252 if $t < 0
2267 1017 4235 if (not defined $etc->{$s} or $etc_r + $t < $etc->{$s})
2304 0 82 if $seen->contains($p)
2308 24 58 if $seen->size == $V or $u eq $v
2310 41 27 if not @path or $path[-1] ne $u
2316 1903 215 unless $c0->{$u}
2318 151 64 unless defined $w
2319 141 74 if (defined $d->{$v}) { }
2320 141 0 if (defined $d->{$u})
2321 14 127 if ($d->{$v} > $d->{$u} + $w)
2328 74 0 if (defined $d->{$u})
2340 0 11 unless defined $r
2351 572 974 if $g->undirected
2354 78 11 unless $i == $V - 1
2359 148 13 if (defined $d{$u} and defined $d{$v})
2362 1 147 if defined $d and $d{$v} > $d{$u} + $d
2400 0 30 if $seen->contains($p)
2404 0 30 if $seen->size == $V
2480 0 628 unless defined $l
2482 50 478 if ($u ne $v and !defined($max) || $l > $max)
2486 18 510 if ($u ne $v and !defined($min) || $l < $min)
2497 0 11 wantarray ? :
11 4 defined $maxp ? :
2505 2 3 if (defined $u)
2506 0 1 wantarray ? :
1 1 if defined $v
2512 6 3 unless defined $l and !defined($max) || $l > $max
2516 0 1 wantarray ? :
2518 1 2 if (defined $v)
2523 7 2 unless defined $l and !defined($max) || $l > $max
2527 0 1 wantarray ? :
2530 0 2 wantarray ? :
2 0 defined $maxp ? :
2536 7 158 unless &is_connected
2540 729 366 unless defined $l and !defined($max) || $l > $max
2543 155 3 defined $max ? :
2550 2 9 if (defined $u)
2551 0 1 wantarray ? :
1 1 if defined $v
2557 8 1 unless defined $l and !defined($min) || $l < $min
2562 0 1 wantarray ? :
2564 1 8 if (defined $v)
2569 6 3 unless defined $l and !defined($min) || $l < $min
2574 0 1 wantarray ? :
2577 6 2 unless defined $minp
2578 0 2 wantarray ? :
2587 20 69 if defined $x and $x < $radius
2595 9 1 unless defined $delta
2600 7 3 if (defined $r and $r != $Inf)
2603 0 53 unless defined $e and $e != $Inf
2604 15 38 if abs $e - $r <= $delta
2619 83 726 unless my $l = $t->path_length($u, $v)
2620 418 308 if defined $A[0] and $u ne $A[0]
2621 163 145 if defined $A[1] and $v ne $A[1]
2625 8 1 $m ? :
2633 16 16 unless &is_multiedged or &is_countedged
2638 8 6 if grep(($u eq $_), @v)
2639 2 4 if $g->get_edge_count(@$e) > 1
2645 16 16 unless &is_multiedged or &is_countedged
2647 4 12 if grep(($g->get_edge_count(@$_) > 1), &_edges05)
2656 16 12 if grep(($u eq $_), @v)
2657 2 10 if $m and $g->get_edge_count($u, @v) > 1
2671 7 7 if exists $_factorial{$i}
2679 0 39 if $n < 0
2680 4 35 unless exists $_factorial{$n}
2686 8 23 unless &vertices == $g1->vertices
2687 6 17 unless &_edges05 == $g1->_edges05
2692 0 17 unless keys %d0 == keys %d1
2696 0 31 unless exists $d1{$da} and keys %{$d0{$da};} == keys %{$d1{$da};}
2699 4 27 if grep((!(exists $d1{$da}{$_} && $d0{$da}{$_} == $d1{$da}{$_})), keys %{$d0{$da};})
2702 0 27 if grep(($d1{$da}{$_} != $d0{$da}{$_}), keys %{$d0{$da};})
2705 0 13 unless keys %d1 == 0
2722 1 1 unless my(@v) = $g->vertices
2739 9 6 if (@neigh > 1) { }
2749 1 0 wantarray ? :
2783 157 184 if ($d{$w} < 0)
2788 173 168 if ($d{$w} == $d{$v} + 1)
2802 157 15 if $w ne $s