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 362 335 $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 462 2124 if $V->[1] & 8
292 1391 14 unless &is_multivertexed or &is_countvertexed
293 2 12 if wantarray
307 11 15549 if @_ != 3
320 56 0 @i ? :
332 267 18 @i ? :
338 0 38206 if grep((!defined($_)), @args)
341 344 37862 if $V->[1] & 8 or $deep
344 1293 36569 if not $ensure and @non_exist
345 36 36533 if @non_exist
353 4 19997 if $Ea and @_ != $Ea + 1
356 1411 18586 if (my(@i) = &_vertex_ids) != @_ - 1
357 11 0 $directed ? :
11 18575 if $deep
358 15139 3436 unless $directed
366 6 16 if (my(@i) = $V->get_ids_by_paths(\@args)) != @args
373 55 1253 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 25611 if (my(@i) = $V->get_ids_by_paths(\@args)) != @args
541 4099 21512 unless wantarray
546 3459 1598 if &is_undirected
549 4 1594 if (my(@i) = $V->get_ids_by_paths(\@args)) != @args
551 1399 195 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 446 if (my(@i) = &_vertex_ids) != @_ - 1
629 12 434 if &is_undirected
630 9 437 unless @i and $g->[3]->del_path(\@i)
638 1 183 if @_ != 2
640 6 177 unless defined $V->has_path($_[1])
656 16 964 if (my(@i) = &_vertex_ids) != @_ - 1
657 78 886 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 4690 unless @_ > 1
751 466 4224 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 2121 116 unless $is_vertex or $is_undirected or $is_multi
913 14255 129 unless $is_vertex or $is_multi
914 1544 129 if $is_vertex
916 13 116 $is_undirected ? :
924 25 4608 $is_multi ? :
38 4653 $is_multi ? :
4633 58 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
925 4623 68 $entity eq 'edge' ? :
934 10 1015 $is_multi ? :
14 1099 $is_multi ? :
1025 88 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
935 12 1101 $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 600 $is_multi ? :
2 634 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
963 557 77 $entity eq 'edge' ? :
972 64 11481 $is_multi ? :
38 11507 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
973 11261 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 ? :
32113 68 ref $u eq 'ARRAY' ? :
1035 52 17756 if (&is_multiedged)
1041 14 17742 $deep ? :
1042 15334 2422 if &is_undirected
1044 5 17751 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 491 unless &is_directed
1176 0 491 unless &has_edge
1180 397 94 unless $g->has_edge(@e)
1182 0 491 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 1133 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 1490 if &is_multivertexed
1507 1 19013 if &is_multiedged
1512 4 412 unless &is_multiedged
1517 1 660 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 272 12496 if $v1 eq $v2
1606 5809 255 $is_directed ? :
6027 37 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 4088 0 if (defined $t)
1746 1894 2194 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 2247 unless defined $c
1854 0 2247 if @extra_keys != @$extra_vals
1856 0 2247 if defined $a and ref $a ne "ARRAY"
1858 423 1824 unless (defined $a and $a->[0] == $g->[1])
1865 106 0 unless not defined $v
1867 29 2216 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 120 unless defined(my $root = &List::Util::first(sub { exists $u->{$_}; } , @d))
2070 1 4 unless defined(my $c = &_strongly_connected_components->[0][$i])
2111 14895 1924 if $e->[0] eq $u and $e->[1] eq $v
2113 14895 0 if @BC
2120 15912 19336 if (not exists $state->{'num'}{$v}) { }
907 34341 elsif (defined $state->{'pred'}{$u} and $state->{'pred'}{$u} ne $v and $state->{'num'}{$v} < $state->{'num'}{$u}) { }
2127 14895 1017 if $state->{'low'}{$v} >= $state->{'num'}{$u}
2143 15912 1624 if exists $state{'num'}{$u}
2145 1 1623 unless $state{'stack'}
0 1624 if @{&_empty_array() unless $state{'stack'};}
2167 3014 14522 if @components > 1
2180 0 434 unless _check_cache($_[0], "biconnectivity", [], \&Graph::_biconnectivity_compute, @_[1 .. $#_])
2185 10 3 &edges >= 2 ? :
2189 10 3 &edges >= 2 ? :
2193 10 3 &edges >= 2 ? :
2215 2 0 defined $v2bc->{$v} ? :
2220 0 5 if grep((!defined($_)), my(@vecs) = @$v2bc{@_[1 .. $#_]})
2238 6 4 unless grep exists $j{$_}, @u
2247 0 23 unless (&biconnectivity)[2]
2259 5155 98 unless defined $t
2260 1 5252 if $t < 0
2262 1016 4236 if (not defined $etc->{$s} or $etc_r + $t < $etc->{$s})
2299 0 82 if $seen->contains($p)
2303 24 58 if $seen->size == $V or $u eq $v
2305 41 27 if not @path or $path[-1] ne $u
2311 1903 215 unless $c0->{$u}
2313 151 64 unless defined $w
2314 141 74 if (defined $d->{$v}) { }
2315 141 0 if (defined $d->{$u})
2316 14 127 if ($d->{$v} > $d->{$u} + $w)
2323 74 0 if (defined $d->{$u})
2335 0 11 unless defined $r
2346 572 974 if $g->undirected
2349 78 11 unless $i == $V - 1
2354 148 13 if (defined $d{$u} and defined $d{$v})
2357 1 147 if defined $d and $d{$v} > $d{$u} + $d
2395 0 30 if $seen->contains($p)
2399 0 30 if $seen->size == $V
2475 0 628 unless defined $l
2477 50 478 if ($u ne $v and !defined($max) || $l > $max)
2481 18 510 if ($u ne $v and !defined($min) || $l < $min)
2492 0 11 wantarray ? :
11 4 defined $maxp ? :
2500 2 3 if (defined $u)
2501 0 1 wantarray ? :
1 1 if defined $v
2507 6 3 unless defined $l and !defined($max) || $l > $max
2511 0 1 wantarray ? :
2513 1 2 if (defined $v)
2518 7 2 unless defined $l and !defined($max) || $l > $max
2522 0 1 wantarray ? :
2525 0 2 wantarray ? :
2 0 defined $maxp ? :
2531 7 158 unless &is_connected
2535 729 366 unless defined $l and !defined($max) || $l > $max
2538 155 3 defined $max ? :
2545 2 9 if (defined $u)
2546 0 1 wantarray ? :
1 1 if defined $v
2552 8 1 unless defined $l and !defined($min) || $l < $min
2557 0 1 wantarray ? :
2559 1 8 if (defined $v)
2564 6 3 unless defined $l and !defined($min) || $l < $min
2569 0 1 wantarray ? :
2572 6 2 unless defined $minp
2573 0 2 wantarray ? :
2582 20 69 if defined $x and $x < $radius
2590 9 1 unless defined $delta
2595 7 3 if (defined $r and $r != $Inf)
2598 0 53 unless defined $e and $e != $Inf
2599 15 38 if abs $e - $r <= $delta
2614 83 726 unless my $l = $t->path_length($u, $v)
2615 418 308 if defined $A[0] and $u ne $A[0]
2616 163 145 if defined $A[1] and $v ne $A[1]
2620 8 1 $m ? :
2628 16 16 unless &is_multiedged or &is_countedged
2633 8 6 if grep(($u eq $_), @v)
2634 2 4 if $g->get_edge_count(@$e) > 1
2640 16 16 unless &is_multiedged or &is_countedged
2642 4 12 if grep(($g->get_edge_count(@$_) > 1), &_edges05)
2651 16 12 if grep(($u eq $_), @v)
2652 2 10 if $m and $g->get_edge_count($u, @v) > 1
2666 7 7 if exists $_factorial{$i}
2674 0 39 if $n < 0
2675 4 35 unless exists $_factorial{$n}
2681 8 23 unless &vertices == $g1->vertices
2682 6 17 unless &_edges05 == $g1->_edges05
2687 0 17 unless keys %d0 == keys %d1
2691 0 31 unless exists $d1{$da} and keys %{$d0{$da};} == keys %{$d1{$da};}
2694 4 27 if grep((!(exists $d1{$da}{$_} && $d0{$da}{$_} == $d1{$da}{$_})), keys %{$d0{$da};})
2697 0 27 if grep(($d1{$da}{$_} != $d0{$da}{$_}), keys %{$d0{$da};})
2700 0 13 unless keys %d1 == 0
2717 1 1 unless my(@v) = $g->vertices
2734 9 6 if (@neigh > 1) { }
2744 1 0 wantarray ? :
2778 157 184 if ($d{$w} < 0)
2783 173 168 if ($d{$w} == $d{$v} + 1)
2797 157 15 if $w ne $s