Branch Coverage

blib/lib/Graph.pm
Criterion Covered Total %
branch 622 720 86.3


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 359 335 $u ? :
89 4 1302 $h ? :
3135 1306 $u ? :
117 588 7458 if delete $opt->{$flag}
118 0 8046 if delete $$opt{"non$flag"}
124 5 1 unless exists $opt->{$key}
130 1219 6 unless my(@opt) = keys %$opt
131 1 5 @opt > 1 ? :
140 0 106 if $g->has_union_find
158 274 620 if exists $opt->{'directed'}
172 106 788 if ref $class and $class->isa("Graph")
183 95 799 if ($opt{'vertices'})
185 0 95 if ref $opt{'vertices'} ne "ARRAY"
190 23 871 if ($opt{'edges'})
192 0 23 if ref $opt{'edges'} ne "ARRAY"
198 1 890 if $vflags & 1 and $vflags & 2
201 1 889 if $eflags & 1 and $eflags & 2
211 76 813 if @V
213 0 889 if grep((ref $_ ne "ARRAY"), @E)
217 5 884 if $gflags & 16
225 105 784 $vflags ? :
230 12 46 $is_hyper ? :
58 831 $is_hyper || $eflags & 18446744073709551611 ? :
272 5 2096 if @_ != 2
273 1 2095 if grep((!defined($_)), @_)
280 462 2115 if $V->[1] & 8
292 1391 14 unless &is_multivertexed or &is_countvertexed
293 2 12 if wantarray
307 11 15508 if @_ != 3
320 56 0 @i ? :
332 267 18 @i ? :
338 0 37908 if grep((!defined($_)), @args)
341 344 37564 if $V->[1] & 8 or $deep
344 1289 36275 if not $ensure and @non_exist
345 36 36239 if @non_exist
353 4 19841 if $Ea and @_ != $Ea + 1
356 1407 18434 if (my(@i) = &_vertex_ids) != @_ - 1
357 11 0 $directed ? :
11 18423 if $deep
358 15028 3395 unless $directed
366 6 16 if (my(@i) = $V->get_ids_by_paths(\@args)) != @args
373 55 1250 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 469 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 284 unless wantarray
531 30 216 if &is_undirected
532 0 216 unless wantarray
539 6 25568 if (my(@i) = $V->get_ids_by_paths(\@args)) != @args
541 4081 21487 unless wantarray
546 3448 1599 if &is_undirected
549 4 1595 if (my(@i) = $V->get_ids_by_paths(\@args)) != @args
551 1396 199 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 449 if (my(@i) = &_vertex_ids) != @_ - 1
629 12 437 if &is_undirected
630 9 440 unless @i and $g->[3]->del_path(\@i)
638 1 183 if @_ != 2
640 6 177 unless defined $V->has_path($_[1])
656 16 954 if (my(@i) = &_vertex_ids) != @_ - 1
657 78 876 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 4676 unless @_ > 1
751 459 4217 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 2099 116 unless $is_vertex or $is_undirected or $is_multi
913 14142 129 unless $is_vertex or $is_multi
914 1546 129 if $is_vertex
916 13 116 $is_undirected ? :
924 25 4567 $is_multi ? :
38 4620 $is_multi ? :
4592 66 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
925 4590 68 $entity eq 'edge' ? :
934 10 1015 $is_multi ? :
14 1101 $is_multi ? :
1025 90 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
935 12 1103 $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 590 $is_multi ? :
2 624 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
963 547 77 $entity eq 'edge' ? :
972 64 11389 $is_multi ? :
38 11415 unless &{"has_" . $entity . ($is_multi ? "_by_id" : "");}
973 11169 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 2263 if (&is_multivertexed)
1023 2258 5 unless &has_union_find
1032 67 1 @args ? :
32255 68 ref $u eq 'ARRAY' ? :
1035 52 17685 if (&is_multiedged)
1041 14 17671 $deep ? :
1042 15297 2388 if &is_undirected
1044 5 17680 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 481 unless &is_directed
1176 0 481 unless &has_edge
1180 400 81 unless $g->has_edge(@e)
1182 0 481 if $a
1188 3 17 unless &directed
1201 12 7 $directed ? :
1220 0 20 unless ref $src eq "ARRAY" and !defined($dst) || ref $dst eq 'ARRAY'
1225 2 18 $dst ? :
1226 2 18 $dst ? :
1228 48 39 $directed ? :
1447 5 38 @_ ? :
1448 30 13 defined $got ? :
1449 43 0 if (my(@caller2) = caller 2) { }
1459 10 0 unless @_
1465 14 1133 unless &is_undirected
1469 10 251 unless &is_directed
1473 1 2 unless &is_acyclic
1478 2 5 unless &is_directed
1479 3 4 unless &is_acyclic
1480 5 2 if @got
1484 2 9 unless &is_hyperedged
1488 4 222 unless &is_multivertexed
1493 1 1492 if &is_multivertexed
1498 1 18845 if &is_multiedged
1503 4 412 unless &is_multiedged
1508 1 663 if &has_union_find
1513 3 1095 unless (@_ == 1 and ref $_[0] eq "ARRAY")
1517 0 1095 unless (@opt % 2 == 0)
1548 0 80 $^P && $] < 5.009003 ? :
1552 3 11 @_ % 2 == 0 ? :
1555 2 12 unless defined $opt{'vertices'}
1556 4 8 if exists $opt{'random_seed'}
1557 1 11 if exists $opt{'random_edge'}
1559 1 11 if (my $ref = ref $opt{'vertices'}) { }
1560 0 1 if $ref ne "ARRAY"
1571 0 2 if exists $opt{'edges'} and exists $opt{'edges_fill'}
1572 1 11 exists $opt{'edges_fill'} ? :
1577 0 12 if $V < 2
1578 11 1 if my $is_directed = $g->directed
1579 9 3 unless defined $E
1582 3 9 unless defined $random_edge
1584 0 12 if $p > 1 and not $g->countedged || $g->multiedged
1595 281 13080 if $v1 eq $v2
1597 5809 258 $is_directed ? :
6027 40 if ($q and $q == 1 || rand() <= $q and not exists $v1_v2{$v1}{$v2} and $is_directed ? 1 : !exists $v1_v2{$v2}{$v1})
1603 12 6015 unless $E
1641 0 23 exists $attr->{'attribute'} ? :
1644 0 23 exists $attr->{'comparator'} ? :
1670 1121 454 if $UF->same(@$e)
1691 3 147 @args == 1 ? :
1697 1 149 if (exists $opt{'start'})
1701 107 43 if (exists $opt{'first_root'}) { }
1702 1 106 if (ref $opt{'first_root'} eq 'CODE') { }
1716 0 149 $opt{'next_numeric'} ? :
0 149 $opt{'next_alphabetic'} ? :
1 149 exists $opt{'next_root'} ? :
1719 0 150 exists $opt{'attribute'} ? :
1734 4039 0 if (defined $t)
1737 1894 2145 if (exists $unseenh->{$v})
1744 1 103 unless defined $next
1745 103 0 $code ? :
1746 81 22 unless defined $r
1772 2 3 &is_directed && &is_acyclic ? :
1786 1 4 if ($eic) { }
1794 1 1 $hac ? :
1843 0 2247 unless defined $c
1845 0 2247 if @extra_keys != @$extra_vals
1847 0 2247 if defined $a and ref $a ne "ARRAY"
1849 423 1824 unless (defined $a and $a->[0] == $g->[1])
1856 106 0 unless not defined $v
1858 29 2216 if ($extra_invalid)
1872 5 35 unless my(@v) = $g->unique_vertices
1873 9 26 if (my $UF = &has_union_find) { }
1880 0 20 unless defined $cc
1882 13 7 unless exists $cc2counter{$cc}
1894 8 26 if keys %r
1922 0 41 unless $value
41 16 $value ? :
1934 14 14 if (my $UF = &has_union_find) { }
1936 4 10 if @ids != @args
1941 4 20 if grep((!defined($_)), @components)
1952 2 18 if ($g->has_union_find and $g->vertices == 1) { }
2020 14 120 unless defined(my $root = &List::Util::first(sub { exists $u->{$_}; } , @d))
2061 1 4 unless defined(my $c = &_strongly_connected_components->[0][$i])
2102 14895 1924 if $e->[0] eq $u and $e->[1] eq $v
2104 14895 0 if @BC
2111 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}) { }
2118 14895 1017 if $state->{'low'}{$v} >= $state->{'num'}{$u}
2134 15912 1624 if exists $state{'num'}{$u}
2136 1 1623 unless $state{'stack'}
0 1624 if @{&_empty_array() unless $state{'stack'};}
2158 3014 14522 if @components > 1
2171 0 434 unless _check_cache($_[0], "biconnectivity", [], \&Graph::_biconnectivity_compute, @_[1 .. $#_])
2176 10 3 &edges >= 2 ? :
2180 10 3 &edges >= 2 ? :
2184 10 3 &edges >= 2 ? :
2206 2 0 defined $v2bc->{$v} ? :
2211 0 5 if grep((!defined($_)), my(@vecs) = @$v2bc{@_[1 .. $#_]})
2229 6 4 unless grep exists $j{$_}, @u
2238 0 23 unless (&biconnectivity)[2]
2250 5155 98 unless defined $t
2251 1 5252 if $t < 0
2253 1018 4234 if (not defined $etc->{$s} or $etc_r + $t < $etc->{$s})
2290 0 82 if $seen->contains($p)
2294 24 58 if $seen->size == $V or $u eq $v
2296 41 27 if not @path or $path[-1] ne $u
2302 1903 215 unless $c0->{$u}
2304 151 64 unless defined $w
2305 141 74 if (defined $d->{$v}) { }
2306 141 0 if (defined $d->{$u})
2307 14 127 if ($d->{$v} > $d->{$u} + $w)
2314 74 0 if (defined $d->{$u})
2326 0 11 unless defined $r
2337 572 974 if $g->undirected
2340 78 11 unless $i == $V - 1
2345 148 13 if (defined $d{$u} and defined $d{$v})
2348 1 147 if defined $d and $d{$v} > $d{$u} + $d
2386 0 30 if $seen->contains($p)
2390 0 30 if $seen->size == $V
2466 0 628 unless defined $l
2468 50 478 if ($u ne $v and !defined($max) || $l > $max)
2472 18 510 if ($u ne $v and !defined($min) || $l < $min)
2483 0 11 wantarray ? :
11 4 defined $maxp ? :
2491 2 3 if (defined $u)
2492 0 1 wantarray ? :
1 1 if defined $v
2498 6 3 unless defined $l and !defined($max) || $l > $max
2502 0 1 wantarray ? :
2504 1 2 if (defined $v)
2509 7 2 unless defined $l and !defined($max) || $l > $max
2513 0 1 wantarray ? :
2516 0 2 wantarray ? :
2 0 defined $maxp ? :
2522 7 158 unless &is_connected
2526 729 366 unless defined $l and !defined($max) || $l > $max
2529 155 3 defined $max ? :
2536 2 9 if (defined $u)
2537 0 1 wantarray ? :
1 1 if defined $v
2543 8 1 unless defined $l and !defined($min) || $l < $min
2548 0 1 wantarray ? :
2550 1 8 if (defined $v)
2555 6 3 unless defined $l and !defined($min) || $l < $min
2560 0 1 wantarray ? :
2563 6 2 unless defined $minp
2564 0 2 wantarray ? :
2573 20 69 if defined $x and $x < $radius
2581 9 1 unless defined $delta
2586 7 3 if (defined $r and $r != $Inf)
2589 0 53 unless defined $e and $e != $Inf
2590 15 38 if abs $e - $r <= $delta
2605 83 726 unless my $l = $t->path_length($u, $v)
2606 418 308 if defined $A[0] and $u ne $A[0]
2607 163 145 if defined $A[1] and $v ne $A[1]
2611 8 1 $m ? :
2619 16 16 unless &is_multiedged or &is_countedged
2624 8 6 if grep(($u eq $_), @v)
2625 2 4 if $g->get_edge_count(@$e) > 1
2631 16 16 unless &is_multiedged or &is_countedged
2633 4 12 if grep(($g->get_edge_count(@$_) > 1), &_edges05)
2642 16 12 if grep(($u eq $_), @v)
2643 2 10 if $m and $g->get_edge_count($u, @v) > 1
2657 7 7 if exists $_factorial{$i}
2665 0 39 if $n < 0
2666 4 35 unless exists $_factorial{$n}
2672 8 23 unless &vertices == $g1->vertices
2673 6 17 unless &_edges05 == $g1->_edges05
2678 0 17 unless keys %d0 == keys %d1
2682 0 31 unless exists $d1{$da} and keys %{$d0{$da};} == keys %{$d1{$da};}
2685 4 27 if grep((!(exists $d1{$da}{$_} && $d0{$da}{$_} == $d1{$da}{$_})), keys %{$d0{$da};})
2688 0 27 if grep(($d1{$da}{$_} != $d0{$da}{$_}), keys %{$d0{$da};})
2691 0 13 unless keys %d1 == 0
2708 1 1 unless my(@v) = $g->vertices
2725 9 6 if (@neigh > 1) { }
2735 1 0 wantarray ? :
2769 157 184 if ($d{$w} < 0)
2774 173 168 if ($d{$w} == $d{$v} + 1)
2788 157 15 if $w ne $s