Branch Coverage

blib/lib/Graph.pm
Criterion Covered Total %
branch 674 808 83.4


line true false branch
5 0 84 if $ENV{'GRAPH_ALLOW_RECURSION'}
30 21 4 if defined $can_deep_copy_Storable
31 0 4 if $] < "5.01"
51 84 0 if ($] >= 5.022) { }
57 0 0 unless eval { do { $Inf = "Inf" } } or eval { do { $Inf = "Inf" } } or eval { do { $Inf = "Inf" } }
86 328 317 $u ? :
89 4 1373 $h ? :
3145 1377 $u ? :
117 1960 18632 if delete $opt->{$flag}
118 0 20592 if delete $$opt{"non$flag"}
124 5 1 unless exists $opt->{$key}
130 2639 6 unless my(@opt) = keys %$opt
131 1 5 @opt > 1 ? :
140 1 1495 if $g->has_union_find
158 290 1998 if exists $opt->{'directed'}
172 1496 792 if ref $class and $class->isa("Graph")
183 80 2208 if ($opt{'vertices'})
185 0 80 if ref $opt{'vertices'} ne "ARRAY"
190 8 2280 if ($opt{'edges'})
192 0 8 if ref $opt{'edges'} ne "ARRAY"
194 0 8 if grep((ref $_ ne "ARRAY"), @E)
200 1 2284 if $vflags & 1 and $vflags & 2
203 1 2283 if $eflags & 1 and $eflags & 2
211 6 2277 if $gflags & 16
213 74 2209 if @V
214 8 2275 if @E
221 135 2148 $vflags ? :
226 19 70 $is_hyper ? :
89 2194 $is_hyper || $eflags & 18446744073709551611 ? :
268 5 2117 if @_ != 2
269 1 2116 if grep((!defined($_)), @_)
276 534 11491 if $V->[1] & 8
288 2346 13 unless &is_multivertexed or &is_countvertexed
289 1 12 if wantarray
303 11 37699 if @_ != 3
316 114 0 @i ? :
328 616 19 @i ? :
334 0 77560 if grep((!defined($_)), @args)
337 344 77216 if $V->[1] & 8 or $deep
340 1305 75911 if not $ensure and @non_exist
341 51 75860 if @non_exist
349 4 58518 if $Ea and @_ != $Ea + 1
352 1422 57096 if (my(@i) = &_vertex_ids) != @_ - 1
353 11 0 $directed ? :
11 57085 if $deep
354 47806 9279 unless $directed
362 6 16 if (my(@i) = $V->get_ids_by_paths(\@args)) != @args
369 55 1256 unless wantarray
378 332 53 unless &is_multiedged or &is_countedged
379 39 14 if wantarray
397 1 43 if $V->has_path_by_multi_id(my(@args) = ($v, $id))
399 0 43 if &has_union_find
408 0 6 if &has_union_find
423 1 6 unless &has_vertex_by_id
424 3 3 if ($g->[2]->get_multi_ids($v) == 1)
430 3 0 unless &is_undirected
449 30 84 if &is_undirected
452 2 112 if &has_union_find
460 6 7 if &is_undirected
463 0 13 if &has_union_find
471 19 306 if @i < @_ - 2
473 48 258 if &is_undirected
483 0 5 if @i < @_ - 2
485 0 5 if &is_undirected
486 1 4 unless $E->has_path_by_multi_id(my(@args) = (\@i, $id))
494 0 197 unless @_ - 1 == (my(@i) = &_vertex_ids)
503 80 115 if &is_undirected
505 114 1 wantarray ? :
511 4 1665 if (my(@i) = $V->get_ids_by_paths(\@args, &is_hyperedged && &is_directed)) != @args
516 0 331 if &is_undirected
519 3 328 if (my(@i) = $V->get_ids_by_paths(\@args, &is_hyperedged && &is_directed)) != @args
524 1 11 unless wantarray
529 0 1474 unless wantarray
534 30 216 if &is_undirected
535 0 216 unless wantarray
542 6 18480 if (my(@i) = $V->get_ids_by_paths(\@args)) != @args
544 4063 14417 unless wantarray
549 3430 1378 if &is_undirected
552 4 1374 if (my(@i) = $V->get_ids_by_paths(\@args)) != @args
554 1175 199 unless wantarray
563 80 86 $self_only_if_loop ? :
568 124 211 if $next->is_null
572 80 86 if $self_only_if_loop
573 160 6 wantarray ? :
609 82 9534 if &is_directed
610 9604 12 wantarray ? :
621 18 18 &directed ? :
625 9 8 &directed ? :
631 5 459 if (my(@i) = &_vertex_ids) != @_ - 1
632 12 447 if &is_undirected
633 9 450 unless @i and $g->[3]->del_path(\@i)
641 1 189 if @_ != 2
643 6 183 unless defined $V->has_path($_[1])
659 16 1172 if (my(@i) = &_vertex_ids) != @_ - 1
660 102 1070 if &is_undirected
690 0 232 unless @_ > 1 and &has_vertex
693 5 227 if &is_undirected and &is_self_loop_vertex
699 0 208 unless @_ > 1 and &has_vertex
702 1 207 if &is_undirected and &is_self_loop_vertex
707 0 42 unless @_ > 1 and &has_vertex
708 24 18 &is_undirected ? :
712 36 2 if @_ > 1
713 1 1 if &is_directed
723 0 36 unless @_ > 1
724 10 26 if &successors == 0
728 0 36 unless @_ > 1
729 7 29 if &predecessors == 0
733 0 36 unless @_ > 1
738 0 36 unless @_ > 1
743 0 36 unless @_ > 1
748 0 36 unless @_ > 1
753 0 4437 unless @_ > 1
754 459 3978 if &predecessors == 0
758 0 36 unless @_ > 1
760 8 28 if my $isl = &is_self_loop_vertex
761 13 23 if $s == 0
762 15 8 if &is_undirected
764 2 6 if $isl
769 0 36 unless @_ > 1
770 29 7 unless &predecessors == 0
774 0 108 unless @_ > 1
775 22 86 if grep(($_ eq $_[1]), &successors)
830 13 30 unless $g->has_edge($u, $v)
848 1 8 if @_ == 1
866 1 1 if &is_undirected
872 2 0 $t->has_state('a_cycle') ? :
916 0 3 unless &has_edge
0 3 &is_undirected ? :
0 2 unless &has_edge
0 2 &is_undirected ? :
0 3 unless &has_vertex
0 2 unless &has_vertex
61 11224 unless &has_edge
10332 892 &is_undirected ? :
0 3 unless &has_edge
0 3 &is_undirected ? :
0 3 unless &has_edge
0 3 &is_undirected ? :
1 538 unless &has_edge
15 523 &is_undirected ? :
7 280 unless &has_vertex
0 3 unless &has_vertex
0 3 unless &has_vertex
1 62 unless &has_vertex
1 5 unless &has_edge
0 5 &is_undirected ? :
0 10 unless &has_edge
0 10 &is_undirected ? :
1 5 unless &has_vertex
0 10 unless &has_vertex
4588 36 unless &has_edge
3936 688 &is_undirected ? :
2 3 unless &has_edge
2 3 &is_undirected ? :
48 10 unless &has_vertex
1033 84 unless &has_vertex
921 0 3 unless &has_edge_by_id
0 3 &is_undirected ? :
0 2 unless &has_edge_by_id
0 2 &is_undirected ? :
0 3 unless &has_vertex_by_id
0 2 unless &has_vertex_by_id
0 129 unless &has_edge_by_id
2 127 &is_undirected ? :
0 3 unless &has_edge_by_id
0 3 &is_undirected ? :
0 3 unless &has_edge_by_id
0 3 &is_undirected ? :
0 85 unless &has_edge_by_id
37 48 &is_undirected ? :
0 17 unless &has_vertex_by_id
0 3 unless &has_vertex_by_id
0 3 unless &has_vertex_by_id
0 78 unless &has_vertex_by_id
1 5 unless &has_edge_by_id
0 5 &is_undirected ? :
0 10 unless &has_edge_by_id
0 10 &is_undirected ? :
1 5 unless &has_vertex_by_id
0 10 unless &has_vertex_by_id
34 9 unless &has_edge_by_id
5 38 &is_undirected ? :
18 1 unless &has_edge_by_id
6 13 &is_undirected ? :
3 9 unless &has_vertex_by_id
14 1 unless &has_vertex_by_id
927 0 5740 unless defined $name
928 81 5659 &is_multiedged ? :
936 1 3523 if (&is_multivertexed)
942 3518 5 unless &has_union_find
951 105 1 @args ? :
58165 106 ref $u eq 'ARRAY' ? :
954 25 40791 if (&is_multiedged)
960 10 40781 $deep ? :
961 32956 7835 if &is_undirected
963 15 40776 if $uf
973 0 0 @_ ? :
8 0 ref $u eq 'ARRAY' ? :
997 1 2 if (&is_multivertexed) { }
1011 1 2 if (&is_multiedged) { }
1026 13 9 if (&is_multivertexed) { }
1042 36 4 unless $g->get_edge_attributes(@$e)
65 40 $multi_e ? :
1044 12 93 if ($is_hyper) { }
1046 8 4 if ($is_directed) { }
1054 39 54 unless $is_directed
1057 4 18 $is_hyper ? :
1082 24 0 &_can_deep_copy_Storable() ? :
1102 1 0 if $] >= "5.008"
1109 1 16 if grep ref($_), &_vertices05
1117 0 493 unless &is_directed
1118 0 493 unless &has_edge
1122 408 85 unless $g->has_edge(@e)
1124 0 493 if $a
1130 3 17 unless &directed
1143 12 7 $directed ? :
1154 1 2 wantarray ? :
1159 22 45 if (not @$p || @$x and @$r)
1165 13 64 if $g->has_edge($pivot, $v)
1188 0 1222 unless ref $src eq "ARRAY" and !defined($dst) || ref $dst eq 'ARRAY'
1193 4 1218 $dst ? :
1194 4 1218 $dst ? :
1196 12 1210 if ($directed) { }
1199 2 1208 $dst ? :
1435 5 38 @_ ? :
1436 30 13 defined $got ? :
1437 43 0 if (my(@caller2) = caller 2) { }
1447 10 0 unless @_
1453 14 1198 unless &is_undirected
1457 10 209 unless &is_directed
1461 1 2 unless &is_acyclic
1466 2 5 unless &is_directed
1467 3 4 unless &is_acyclic
1468 5 2 if @got
1472 2 9 unless &is_hyperedged
1476 4 498 unless &is_multivertexed
1481 1 1564 if &is_multivertexed
1486 1 19093 if &is_multiedged
1491 4 1001 unless &is_multiedged
1496 1 688 if &has_union_find
1501 3 2469 unless (@_ == 1 and ref $_[0] eq "ARRAY")
1505 0 2469 unless (@opt % 2 == 0)
1536 0 84 $^P && $] < 5.009003 ? :
1540 3 11 @_ % 2 == 0 ? :
1543 2 12 unless defined $opt{'vertices'}
1545 0 2 if exists $opt{'edges'} and exists $opt{'edges_fill'}
1546 4 8 if exists $opt{'random_seed'}
1549 1 11 if (my $ref = ref $opt{'vertices'}) { }
1550 0 1 if $ref ne "ARRAY"
1559 1 11 exists $opt{'edges_fill'} ? :
1563 0 12 if $V < 2
1564 11 1 if $g->directed
1565 9 3 unless defined $E
1568 11 1 unless defined $random_edge
1569 0 12 if $p > 1 and not $g->countedged || $g->multiedged
1579 327 14133 if $v1 eq $v2
1581 6027 7826 if ($q and $q == 1 || rand() <= $q and not $g->has_edge($v1, $v2))
1585 12 6015 unless $E
1623 0 23 exists $attr->{'attribute'} ? :
1626 0 23 exists $attr->{'comparator'} ? :
1652 1158 454 if $UF->same(@$e)
1673 3 161 @args == 1 ? :
1679 1 163 if (exists $opt{'start'})
1683 121 43 if (exists $opt{'first_root'}) { }
1684 1 120 if (ref $opt{'first_root'} eq 'CODE') { }
1698 0 163 $opt{'next_numeric'} ? :
0 163 $opt{'next_alphabetic'} ? :
1 163 exists $opt{'next_root'} ? :
1701 0 164 exists $opt{'attribute'} ? :
1716 4124 0 if (defined $t)
1719 1909 2215 if (exists $unseenh->{$v})
1726 1 106 unless defined $next
1727 106 0 $code ? :
1728 84 22 unless defined $r
1754 2 3 &is_directed && &is_acyclic ? :
1768 1 4 if ($eic) { }
1776 1 1 $hac ? :
1783 10 73 if (&is_multivertexed) { }
1785 13 20 if ($attr_too) { }
1793 2 71 if ($attr_too) { }
1804 10 73 if (&is_multiedged) { }
1807 12 16 if ($attr_too) { }
1809 4 8 if $mirror
1812 4 12 if $mirror
1817 2 71 if ($attr_too) { }
1820 0 2 if ($mirror)
1825 66 5 !$mirror ? :
1881 15314 15570 if $colors{$_[0]} == $colors{$_[1]}
1940 0 2285 unless defined $c
1942 0 2285 if @extra_keys != @$extra_vals
1944 0 2285 if defined $a and ref $a ne "ARRAY"
1946 459 1826 unless (defined $a and $a->[0] == $g->[1])
1953 120 0 unless not defined $v
1955 31 2252 if ($extra_invalid)
1969 6 39 unless my(@v) = $g->unique_vertices
1970 9 30 if (my $UF = &has_union_find) { }
1977 0 20 unless defined $cc
1979 13 7 unless exists $cc2counter{$cc}
1991 10 30 if keys %r
2019 0 41 unless $value
41 16 $value ? :
2031 14 14 if (my $UF = &has_union_find) { }
2033 4 10 if @ids != @args
2038 4 20 if grep((!defined($_)), @components)
2049 2 18 if ($g->has_union_find and $g->vertices == 1) { }
2124 14 127 unless defined(my $root = &List::Util::first(sub { exists $u->{$_}; } , @d))
2165 1 4 unless defined(my $c = &_strongly_connected_components->[0][$i])
2206 14931 1924 if $e->[0] eq $u and $e->[1] eq $v
2208 14931 0 if @BC
2215 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}) { }
2221 14931 1017 if $state->{'low'}{$v} >= $state->{'num'}{$u}
2238 15948 1660 if exists $state{'num'}{$u}
2240 1 1659 unless $state{'stack'}
0 1660 if @{&_empty_array() unless $state{'stack'};}
2262 3014 14594 if @components > 1
2276 0 470 unless _check_cache($_[0], "biconnectivity", scalar [], \&Graph::_biconnectivity_compute, @_[1 .. $#_])
2281 10 3 &edges >= 2 ? :
2285 10 3 &edges >= 2 ? :
2289 10 3 &edges >= 2 ? :
2313 2 0 defined $v2bc->{$v} ? :
2320 0 5 if grep((!defined($_)), my(@vecs) = @$v2bc{@vs})
2338 6 4 unless grep exists $j{$_}, @u
2347 0 59 unless (&biconnectivity)[2]
2359 5155 123 unless defined $t
2360 1 5277 if $t < 0
2362 1034 4243 if (not defined $etc->{$s} or $etc_r + $t < $etc->{$s})
2399 0 92 if $seen->contains($p)
2403 29 63 if $seen->size == $V or $u eq $v
2405 41 33 if not @path or $path[-1] ne $u
2411 1958 226 unless $c0->{$u}
2413 151 75 unless defined $w
2414 147 79 if (defined $d->{$v}) { }
2415 147 0 if (defined $d->{$u})
2416 15 132 if ($d->{$v} > $d->{$u} + $w)
2423 79 0 if (defined $d->{$u})
2435 0 12 unless defined $r
2446 572 1040 if $g->undirected
2449 83 12 unless $i == $V - 1
2454 159 13 if (defined $d{$u} and defined $d{$v})
2457 1 158 if defined $d and $d{$v} > $d{$u} + $d
2495 0 40 if $seen->contains($p)
2499 0 40 if $seen->size == $V
2575 0 628 unless defined $l
2577 50 478 if ($u ne $v and !defined($max) || $l > $max)
2581 18 510 if ($u ne $v and !defined($min) || $l < $min)
2592 0 11 wantarray ? :
11 4 defined $maxp ? :
2600 2 3 if (defined $u)
2601 0 1 wantarray ? :
1 1 if defined $v
2607 6 3 unless defined $l and !defined($max) || $l > $max
2611 0 1 wantarray ? :
2613 1 2 if (defined $v)
2618 7 2 unless defined $l and !defined($max) || $l > $max
2622 0 1 wantarray ? :
2625 0 2 wantarray ? :
2 0 defined $maxp ? :
2631 7 158 unless &is_connected
2635 729 366 unless defined $l and !defined($max) || $l > $max
2638 155 3 defined $max ? :
2645 2 9 if (defined $u)
2646 0 1 wantarray ? :
1 1 if defined $v
2652 8 1 unless defined $l and !defined($min) || $l < $min
2657 0 1 wantarray ? :
2659 1 8 if (defined $v)
2664 6 3 unless defined $l and !defined($min) || $l < $min
2669 0 1 wantarray ? :
2672 6 2 unless defined $minp
2673 0 2 wantarray ? :
2682 20 69 if defined $x and $x < $radius
2690 9 1 unless defined $delta
2695 7 3 if (defined $r and $r != $Inf)
2698 0 53 unless defined $e and $e != $Inf
2699 15 38 if abs $e - $r <= $delta
2714 83 726 unless my $l = $t->path_length($u, $v)
2715 418 308 if defined $A[0] and $u ne $A[0]
2716 163 145 if defined $A[1] and $v ne $A[1]
2720 8 1 $m ? :
2728 16 16 unless &is_multiedged or &is_countedged
2733 8 6 if grep(($u eq $_), @v)
2734 2 4 if $g->get_edge_count(@$e) > 1
2740 16 16 unless &is_multiedged or &is_countedged
2742 4 12 if grep(($g->get_edge_count(@$_) > 1), &_edges05)
2751 16 12 if grep(($u eq $_), @v)
2752 2 10 if $m and $g->get_edge_count($u, @v) > 1
2766 7 7 if exists $_factorial{$i}
2774 0 39 if $n < 0
2775 4 35 unless exists $_factorial{$n}
2781 8 23 unless &vertices == $g1->vertices
2782 6 17 unless &_edges05 == $g1->_edges05
2787 0 17 unless keys %d0 == keys %d1
2791 0 31 unless exists $d1{$da} and keys %{$d0{$da};} == keys %{$d1{$da};}
2794 4 27 if grep((!(exists $d1{$da}{$_} && $d0{$da}{$_} == $d1{$da}{$_})), keys %{$d0{$da};})
2797 0 27 if grep(($d1{$da}{$_} != $d0{$da}{$_}), keys %{$d0{$da};})
2800 0 13 unless keys %d1 == 0
2817 1 1 unless my(@v) = $g->vertices
2834 9 6 if (@neigh > 1) { }
2844 1 0 wantarray ? :
2878 157 184 if ($d{$w} < 0)
2883 173 168 if ($d{$w} == $d{$v} + 1)
2897 157 15 if $w ne $s
2914 3499 1175 if exists $seen{$key}