| 1 | package Graph::AdjacencyMap; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 84 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 84 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | # $SIG{__DIE__ } = \&Graph::__carp_confess; | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # $SIG{__WARN__} = \&Graph::__carp_confess; | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 84 | my $empty = {}; | |||||||||||||||||||||||||||||||||||||||||
| 10 | 90 | ▶ | sub _empty () { $empty } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_empty: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 84 | my (@FLAGS, %FLAG_COMBOS, %FLAG2I, @FIELDS); | |||||||||||||||||||||||||||||||||||||||||
| 13 | 84 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 84 | @FLAGS = qw(_COUNT _MULTI _UNORD _REF _UNIONFIND _LIGHT _STR); | |||||||||||||||||||||||||||||||||||||||||
| 15 | 84 | %FLAG_COMBOS = ( | |||||||||||||||||||||||||||||||||||||||||
| 16 | _COUNTMULTI => [qw(_COUNT _MULTI)], | ||||||||||||||||||||||||||||||||||||||||||
| 17 | _REFSTR => [qw(_REF _STR)], | ||||||||||||||||||||||||||||||||||||||||||
| 18 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 19 | # Next id, Flags, Arity, Index to path, path to index, | ||||||||||||||||||||||||||||||||||||||||||
| 20 | # successors, predecessors: 2-level hashes to array-ref of path IDs | ||||||||||||||||||||||||||||||||||||||||||
| 21 | # attributes - two-level for MULTI, node/multi count | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 84 | @FIELDS = qw(_n _f _arity _i _pi _s _p _attr _count); | |||||||||||||||||||||||||||||||||||||||||
| 23 | 84 | for my $i (0..$#FLAGS) { | |||||||||||||||||||||||||||||||||||||||||
| 24 | 588 | my $n = $FLAGS[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 588 | my $f = 1 << $i; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 588 | $FLAG2I{$n} = $f; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 84 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | *$n = sub () { $f }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 588 | ▶ | *{"_is$n"} = sub { $_[0]->[ 1 ] & $f }; # 1 = _f | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 84 | for my $k (keys %FLAG_COMBOS) { | |||||||||||||||||||||||||||||||||||||||||
| 32 | 168 | my $f = 0; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 168 | $f |= $_ for map $FLAG2I{$_}, @{ $FLAG_COMBOS{$k} }; | |||||||||||||||||||||||||||||||||||||||||
| 34 | 84 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 168 | ▶ | *$k = sub () { return $f }; # return to dodge pointless 5.22 stricture | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 168 | ▶ | *{"_is$k"} = sub { $_[0]->[ 1 ] & $f }; # 1 = _f | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 84 | for my $i (0..$#FIELDS) { | |||||||||||||||||||||||||||||||||||||||||
| 39 | 84 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | *{ $FIELDS[$i] }= sub () { $i }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.4
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 4580 | ▶ | sub _new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_new: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 4580 | my ($class, $flags, $arity) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 4580 | my $hyper = !$arity; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 4580 | my $need_s = $arity != 1; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 4580 | ▶ | my $need_p = $need_s && !($flags & _UNORD); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$need_s && !($flags & 4)
MC/DC100%2/2
$need_s && !($flags & 4)
$need_s
!($flags & 4)
Truth table100%3/3
A && not(B)
A= $need_sB= !($flags & 4)
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 4580 | ▶ | bless [ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0, $flags, $arity, [], {}, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | ($need_s ? {} : undef), ($need_p ? {} : undef), | ||||||||||||||||||||||||||||||||||||||||||
| 52 | [], [], | ||||||||||||||||||||||||||||||||||||||||||
| 53 | ], $class; | ||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 84 | require Exporter; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 84 | ▶ | use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 84 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 59 | 84 | %EXPORT_TAGS = | |||||||||||||||||||||||||||||||||||||||||
| 60 | (flags => [@FLAGS, keys %FLAG_COMBOS, qw(_GEN_ID)], | ||||||||||||||||||||||||||||||||||||||||||
| 61 | fields => \@FIELDS); | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 84 | @EXPORT_OK = map @$_, values %EXPORT_TAGS; | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 84 | my $_GEN_ID = 0; | |||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 299 | ▶ | sub _GEN_ID () { \$_GEN_ID } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_GEN_ID: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 24 | ▶ | sub stringify { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stringify: called CC=11 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 24 | my ($f, $arity, $m) = (@{ $_[0] }[ _f, _arity ], $_[0]); | |||||||||||||||||||||||||||||||||||||||||
| 70 | 24 | my ($multi, @rows) = $f & _MULTI; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 24 | my @p = $m->paths; | |||||||||||||||||||||||||||||||||||||||||
| 72 | @p = $arity == 1 ? sort @p : | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 24 | ▶ | map $_->[0], sort { $a->[1] cmp $b->[1] } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$arity == 0 and not $f & 4
MC/DC100%2/2
$arity == 0 and not $f & 4
$arity == 0
not $f & 4
Truth table100%3/3
A and not(B)
A= $arity == 0B= not $f & 4
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | ($arity == 0 && !($f & _UNORD)) | ||||||||||||||||||||||||||||||||||||||||||
| 75 | ? map [$_, join '|', map "@$_", @$_], @p | ||||||||||||||||||||||||||||||||||||||||||
| 76 | : map [$_,"@$_"], @p; # use the Schwartz | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 24 | ▶ | if ($arity == 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 10 | require Set::Object; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 10 | my ($pre, $suc, @s) = (Set::Object->new(map $_->[0], @p), Set::Object->new(map $_->[1], @p)); | |||||||||||||||||||||||||||||||||||||||||
| 80 | @rows = ([ 'to:', @s = sort $suc->members ], map { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 10 | my $p = $_; | |||||||||||||||||||||||||||||||||||||||||
| 82 | [ $p, map { | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 24 | ▶ | my $text = defined(my $id = $m->has_path([$p, $_])) ? 1 : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 93 | ▶ | my $attrs = !$text ? undef : | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | $multi ? $m->[ _attr ][$id] : $m->_get_path_attrs([$p, $_]); | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 93 | ▶ | defined $attrs ? $m->_dumper($attrs) : $text; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | } @s ]; | ||||||||||||||||||||||||||||||||||||||||||
| 88 | } sort $pre->members); | ||||||||||||||||||||||||||||||||||||||||||
| 89 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 90 | @rows = map { | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 14 | ▶ | my $attrs = $multi | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | ? $m->[ _attr ][ $m->has_path($_) ] : $m->_get_path_attrs($_); | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 33 | ▶ | [ $m->_dumper($_), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | ($m->get_ids_by_paths([ $_ ], 0))[0]. | ||||||||||||||||||||||||||||||||||||||||||
| 95 | (!defined $attrs ? '' : ",".$m->_dumper($attrs)) ]; | ||||||||||||||||||||||||||||||||||||||||||
| 96 | } @p; | ||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 24 | join '', | |||||||||||||||||||||||||||||||||||||||||
| 99 | map "$_\n", | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 24 | "@{[ref $m]} arity=$arity flags: @{[_stringify_fields($m->[ _f ])]}", | |||||||||||||||||||||||||||||||||||||||||
| 101 | map join(' ', map sprintf('%4s', $_), @$_), | ||||||||||||||||||||||||||||||||||||||||||
| 102 | @rows; | ||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 38 | ▶ | sub _stringify_fields { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stringify_fields: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 38 | ▶ | return '0' if !$_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 30 | join '|', grep $_[0] & $FLAG2I{$_}, @FLAGS; | |||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 58 | ▶ | sub _dumper { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dumper: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 58 | my (undef, $got) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 58 | ▶ | return $got if defined $got and !ref $got; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $got and not ref $got
MC/DC50%1/2
defined $got and not ref $got
defined $got
not ref $got
Truth table66%2/3
A and not(B)
A= defined $gotB= not ref $got
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 31 | require Data::Dumper; | |||||||||||||||||||||||||||||||||||||||||
| 114 | 31 | my $dumper = Data::Dumper->new([$got]); | |||||||||||||||||||||||||||||||||||||||||
| 115 | 31 | $dumper->Indent(0)->Terse(1); | |||||||||||||||||||||||||||||||||||||||||
| 116 | 31 | ▶ | $dumper->Sortkeys(1) if $dumper->can("Sortkeys"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 31 | $dumper->Dump; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 90 | ▶ | sub has_any_paths { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_any_paths: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 90 | scalar keys %{ $_[0]->[ _pi ] }; | |||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 162 | ▶ | sub _set_path_attr_common { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_path_attr_common: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 162 | push @_, 0; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 162 | my ($i) = &__set_path; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 162 | my $attr = (my $m = $_[0])->[ _attr ]; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 162 | ▶ | ($m->[ _f ] & _MULTI) ? \$attr->[ $i ]{ $_[2] } : \$attr->[ $i ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 1171 | ▶ | sub _set_path_attrs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_path_attrs: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 1171 | ${ &{ $_[0]->can('_set_path_attr_common') } } = $_[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 4791 | ▶ | sub _set_path_attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_path_attr: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 4791 | ${ &{ $_[0]->can('_set_path_attr_common') } }->{ $_[-2] } = $_[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 315 | ▶ | sub set_paths { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_paths: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 315 | map +($_[0]->__set_path($_, 1))[0], @_[1..$#_]; | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 219 | ▶ | sub set_path_by_multi_id { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_path_by_multi_id: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 219 | push @_, 1; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 219 | goto &__set_path; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 700 | ▶ | sub __set_path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__set_path: called CC=18 SCAR=28.9
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 700 | my $inc_if_exists = pop; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 700 | &__arg; | |||||||||||||||||||||||||||||||||||||||||
| 151 | 700 | my ($f, $a, $map_i, $pi, $map_s, $map_p, $m, $k, $id) = (@{ $_[0] }[ _f, _arity, _i, _pi, _s, _p ], @_); | |||||||||||||||||||||||||||||||||||||||||
| 152 | 700 | my $is_multi = $f & _MULTI; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 700 | my $k_orig = $k; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 700 | ▶ | $k = __strval($k, $f) if $a == 1 && ($f & _REF) && ref($k); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$a == 1 and $f & 8 and ref $k
$a == 1 and $f & 8
MC/DC100%3/3
$a == 1 and $f & 8 and ref $k
$a == 1
$f & 8
ref $k
Truth table100%4/4
A and B and C
A= $a == 1B= $f & 8C= ref $k
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 700 | ▶ | my $l = ($a == 0 && !($f & _UNORD)) ? join '|', map join(' ', sort @$_), @$k : $a == 1 ? "$k" : "@$k"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$a == 0 and not $f & 4
MC/DC100%2/2
$a == 0 and not $f & 4
$a == 0
not $f & 4
Truth table100%3/3
A and not(B)
A= $a == 0B= not $f & 4
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 700 | ▶ | if (exists $pi->{ $l }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 228 | ▶ | return ($pi->{ $l }) if !($inc_if_exists and ($f & _COUNTMULTI)); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$inc_if_exists and $f & &_COUNTMULTI()
MC/DC100%2/2
$inc_if_exists and $f & &_COUNTMULTI()
$inc_if_exists
$f & &_COUNTMULTI()
Truth table100%3/3
A and B
A= $inc_if_existsB= $f & &_COUNTMULTI()
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 55 | my $nc = \$m->[ _count ][ my $i = $pi->{ $l } ]; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 55 | ▶ | $$nc++, return ($i) if !$is_multi; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 34 | my $na = $m->[ _attr ][ $i ]; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 34 | ▶ | if ($id eq _GEN_ID) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 17 | ▶ | $$nc++ while exists $na->{ $$nc }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 17 | $id = $$nc; | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 34 | $na->{ $id } = { }; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 34 | return ($i, $id); | |||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 472 | $map_i->[ $pi->{ $l } = my $i = $m->[ _n ]++ ] = $k_orig; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 472 | ▶ | $m->[ _attr ][ $i ] = { ($id = ($id eq _GEN_ID) ? 0 : $id) => {} } if $is_multi; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 472 | ▶ | $m->[ _count ][ $i ] = $is_multi ? 0 : 1 if ($f & _COUNTMULTI); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 472 | ▶ | _successors_add($f, $a, $map_s, $map_p, $i, $k) if $map_s; # dereffed | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 472 | ($i, $id); | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 174 | ▶ | sub _successors_add { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_successors_add: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 174 | my ($f, $a, $map_s, $map_p, $id, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 174 | my $pairs = _successors_cartesian(($f & _UNORD), $a == 0, $path); | |||||||||||||||||||||||||||||||||||||||||
| 178 | 174 | push @{ $map_s->{ $_->[0] }{ $_->[1] } }, $id for @$pairs; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 174 | ▶ | return if !$map_p; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 119 | push @{ $map_p->{ $_->[1] }{ $_->[0] } }, $id for @$pairs; | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 26 | ▶ | sub _successors_del { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_successors_del: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 26 | my ($f, $a, $map_s, $map_p, $id, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 26 | my $pairs = _successors_cartesian(($f & _UNORD), $a == 0, $path); | |||||||||||||||||||||||||||||||||||||||||
| 186 | 26 | for (@$pairs) { | |||||||||||||||||||||||||||||||||||||||||
| 187 | 63 | my ($p, $s) = @$_; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 63 | my @new = grep $_ != $id, @{ $map_s->{ $p }{ $s } }; | |||||||||||||||||||||||||||||||||||||||||
| 189 | 63 | ▶ | if (@new) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | $map_s->{ $p }{ $s } = \@new; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | ▶ | $map_p->{ $s }{ $p } = \@new if $map_p; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 61 | delete $map_s->{ $p }{ $s }; | |||||||||||||||||||||||||||||||||||||||||
| 195 | 61 | ▶ | delete $map_s->{ $p } if !keys %{ $map_s->{ $p } }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 61 | ▶ | next if !$map_p; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 29 | delete $map_p->{ $s }{ $p }; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 29 | ▶ | delete $map_p->{ $s } if !keys %{ $map_p->{ $s } }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 50177 | ▶ | sub _successors_cartesian { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_successors_cartesian: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 50177 | my ($unord, $hyper, $seq) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 50177 | ▶ | return [ $seq ] if !$unord and !$hyper; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$unord or $hyper
MC/DC100%2/2
$unord or $hyper
$unord
$hyper
Truth table100%3/3
A or B
A= $unordB= $hyper
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 35054 | ▶ | return [] if $unord and $hyper and !@$seq; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$unord and $hyper and not @$seq
$unord and $hyper
MC/DC100%3/3
$unord and $hyper and not @$seq
$unord
$hyper
not @$seq
Truth table100%4/4
A and B and not(C)
A= $unordB= $hyperC= not @$seq
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 35049 | my ($allow_self, $p_s, $s_s, @pairs); | |||||||||||||||||||||||||||||||||||||||||
| 207 | 35049 | ▶ | if ($unord) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 35033 | require Set::Object; | |||||||||||||||||||||||||||||||||||||||||
| 209 | 35033 | my @a = Set::Object->new(@$seq)->members; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 35033 | ($allow_self, $p_s, $s_s) = (@a < 2, \@a, \@a); | |||||||||||||||||||||||||||||||||||||||||
| 211 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 16 | ($allow_self, $p_s, $s_s) = (1, @$seq); | |||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 35049 | for my $p (@$p_s) { | |||||||||||||||||||||||||||||||||||||||||
| 215 | 69850 | ▶ | push @pairs, map [$p, $_], $allow_self ? @$s_s : grep $p != $_, @$s_s; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 35049 | \@pairs; | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 420 | ▶ | sub _get_path_count { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_path_count: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | 420 | ▶ | return 0 unless my ($i) = &__has_path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 397 | my $f = (my $m = $_[0])->[ _f ]; | |||||||||||||||||||||||||||||||||||||||||
| 223 | return | ||||||||||||||||||||||||||||||||||||||||||
| 224 | ($f & _COUNT) ? $m->[ _count ][ $i ] : | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 397 | ▶ | ($f & _MULTI) ? scalar keys %{ $m->[ _attr ][ $i ] } : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 778 | ▶ | sub has_path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_path: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 778 | ( &__has_path )[0]; | |||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | 549 | ▶ | sub has_path_by_multi_id { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_path_by_multi_id: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | 549 | ▶ | return undef unless my ($i) = &__has_path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 454 | return exists $_[0]->[ _attr ][ $i ]{ $_[2] }; | |||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 209 | ▶ | sub del_path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
del_path: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 209 | ▶ | return unless my ($i, $l) = &__has_path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 208 | ▶ | return 1 if &_is_COUNT and --$_[0][ _count ][ $i ] > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
&_is_COUNT and --$_[0][8][$i] > 0
MC/DC100%2/2
&_is_COUNT and --$_[0][8][$i] > 0
&_is_COUNT
--$_[0][8][$i] > 0
Truth table100%3/3
A and B
A= &_is_COUNTB= --$_[0][8][$i] > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 196 | $_[0]->_sequence_del($i, $l); | |||||||||||||||||||||||||||||||||||||||||
| 241 | 196 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 22 | ▶ | sub del_path_by_multi_id { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
del_path_by_multi_id: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 22 | ▶ | return unless my ($i, $l) = &__has_path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 22 | delete((my $attrs = (my $m = $_[0])->[ _attr ][ $i ])->{ $_[2] }); | |||||||||||||||||||||||||||||||||||||||||
| 247 | 22 | ▶ | return 1 if keys %$attrs; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 13 | $m->_sequence_del($i, $l); | |||||||||||||||||||||||||||||||||||||||||
| 249 | 13 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 311 | ▶ | sub get_multi_ids { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_multi_ids: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 311 | ▶ | return unless ((my $m = $_[0])->[ _f ] & _MULTI) and my ($i) = &__has_path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
+(my $m = $_[0])->[1] & 2 and my($i) = &__has_path
MC/DC50%1/2
+(my $m = $_[0])->[1] & 2 and my($i) = &__has_path
+(my $m = $_[0])->[1] & 2
my($i) = &__has_path
Truth table66%2/3
A and B
A= +(my $m = $_[0])->[1] & 2B= my($i) = &__has_path
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 309 | keys %{ $m->[ _attr ][ $i ] }; | |||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 32 | ▶ | sub rename_path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rename_path: called CC=5 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 32 | my ($m, $from, $to) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 259 | 32 | ▶ | return 1 if $m->[ _arity ] != 1; # all integers, no names | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 32 | ▶ | return unless my ($i, $l) = $m->__has_path($from); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 32 | $m->[ _i ][ $i ] = $to; | |||||||||||||||||||||||||||||||||||||||||
| 262 | 32 | ▶ | $to = __strval($to, $m->[ _f ]) if ref($to) and ($m->[ _f ] & _REF); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $to and $m->[1] & 8
MC/DC50%1/2
ref $to and $m->[1] & 8
ref $to
$m->[1] & 8
Truth table66%2/3
A and B
A= ref $toB= $m->[1] & 8
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 32 | $m->[ _pi ]{ $to } = delete $m->[ _pi ]{ $l }; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 32 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 38 | ▶ | sub _del_path_attrs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_del_path_attrs: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | 38 | ▶ | return unless my ($i) = &__has_path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | 38 | my $attr = (my $m = $_[0])->[ _attr ]; | |||||||||||||||||||||||||||||||||||||||||
| 270 | 38 | ▶ | return $attr->[ $i ]{ $_[2] } = undef, 1 if ($m->[ _f ] & _MULTI); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 27 | delete $attr->[ $i ]; | |||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 2923 | ▶ | sub __has_path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__has_path: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 2923 | &__arg; | |||||||||||||||||||||||||||||||||||||||||
| 276 | 2923 | my ($f, $a, $pi, $k) = (@{ $_[0] }[ _f, _arity, _pi ], $_[1]); | |||||||||||||||||||||||||||||||||||||||||
| 277 | 2923 | ▶ | $k = __strval($k, $f) if $a == 1 && ($f & _REF) && ref($k); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$a == 1 and $f & 8 and ref $k
$a == 1 and $f & 8
MC/DC100%3/3
$a == 1 and $f & 8 and ref $k
$a == 1
$f & 8
ref $k
Truth table100%4/4
A and B and C
A= $a == 1B= $f & 8C= ref $k
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 2923 | ▶ | my $l = ($a == 0 && !($f & _UNORD)) ? join '|', map join(' ', sort @$_), @$k : $a == 1 ? "$k" : "@$k"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$a == 0 and not $f & 4
MC/DC100%2/2
$a == 0 and not $f & 4
$a == 0
not $f & 4
Truth table100%3/3
A and not(B)
A= $a == 0B= not $f & 4
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 2923 | my $id = $pi->{ $l }; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 2923 | ▶ | (defined $id ? $id : return, $l); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 564 | ▶ | sub _get_path_attrs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_path_attrs: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | 564 | ▶ | return unless my ($i) = &__has_path; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 555 | my $attrs = (my $m = $_[0])->[ _attr ][ $i ]; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 555 | ▶ | ($m->[ _f ] & _MULTI) ? $attrs->{ $_[2] } : $attrs; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | 82 | ▶ | sub _has_path_attrs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_has_path_attrs: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | 82 | ▶ | keys %{ &{ $_[0]->can('_get_path_attrs') } || return undef } ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
&{$_[0]->can('_get_path_attrs');} || (return undef)
MC/DC100%1/1
&{$_[0]->can('_get_path_attrs');} || (return undef)
&{$_[0]->can('_get_path_attrs');}
Truth table100%2/2
A
A= &{$_[0]->can('_get_path_attrs');}
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | 62 | ▶ | sub _has_path_attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_has_path_attr: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 62 | ▶ | exists(( &{ $_[0]->can('_get_path_attrs') } || return )->{ $_[-1] }); | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
&{$_[0]->can('_get_path_attrs');} || (return)
MC/DC100%1/1
&{$_[0]->can('_get_path_attrs');} || (return)
&{$_[0]->can('_get_path_attrs');}
Truth table100%2/2
A
A= &{$_[0]->can('_get_path_attrs');}
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 11666 | ▶ | sub _get_path_attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_path_attr: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 11666 | ▶ | ( &{ $_[0]->can('_get_path_attrs') } || return )->{ $_[-1] }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
&{$_[0]->can('_get_path_attrs');} || (return)
MC/DC100%1/1
&{$_[0]->can('_get_path_attrs');} || (return)
&{$_[0]->can('_get_path_attrs');}
Truth table100%2/2
A
A= &{$_[0]->can('_get_path_attrs');}
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | 78 | ▶ | sub _get_path_attr_names { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_path_attr_names: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 78 | ▶ | keys %{ &{ $_[0]->can('_get_path_attrs') } || return }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
&{$_[0]->can('_get_path_attrs');} || (return)
MC/DC100%1/1
&{$_[0]->can('_get_path_attrs');} || (return)
&{$_[0]->can('_get_path_attrs');}
Truth table100%2/2
A
A= &{$_[0]->can('_get_path_attrs');}
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 26 | ▶ | sub _get_path_attr_values { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_path_attr_values: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | 26 | ▶ | values %{ &{ $_[0]->can('_get_path_attrs') } || return }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
&{$_[0]->can('_get_path_attrs');} || (return)
MC/DC100%1/1
&{$_[0]->can('_get_path_attrs');} || (return)
&{$_[0]->can('_get_path_attrs');}
Truth table100%2/2
A
A= &{$_[0]->can('_get_path_attrs');}
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 40 | ▶ | sub _del_path_attr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_del_path_attr: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 40 | ▶ | return unless my $attrs = &{ $_[0]->can('_get_path_attrs') }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 36 | ▶ | return 0 unless exists $attrs->{ my $attr = $_[-1] }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 36 | delete $attrs->{$attr}; | |||||||||||||||||||||||||||||||||||||||||
| 313 | 36 | ▶ | return 1 if keys %$attrs; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 15 | &{ $_[0]->can('_del_path_attrs') }; | |||||||||||||||||||||||||||||||||||||||||
| 315 | 15 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | 209 | ▶ | sub _sequence_del { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sequence_del: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 209 | my ($m, $id, $l) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 320 | 209 | my ($f, $a, $map_i, $pi, $map_s, $map_p) = @$m[ _f, _arity, _i, _pi, _s, _p ]; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 209 | delete $pi->{ $l }; | |||||||||||||||||||||||||||||||||||||||||
| 322 | 209 | delete $m->[ $_ ][ $id ] for _count, _attr; | |||||||||||||||||||||||||||||||||||||||||
| 323 | 209 | my $path = delete $map_i->[ $id ]; | |||||||||||||||||||||||||||||||||||||||||
| 324 | 209 | ▶ | _successors_del($f, $a, $map_s, $map_p, $id, $path) if $map_s; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 209 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 17861 | ▶ | sub get_paths_by_ids { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_paths_by_ids: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 17861 | my ($i, undef, $list, $deep) = ( @{ $_[0] }[ _i ], @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 330 | 17861 | ▶ | $deep ? map [ map [ @$i[ @$_ ] ], @$_ ], @$list : map [ @$i[ @$_ ] ], @$list; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | 4882 | ▶ | sub paths { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
paths: called CC=2 SCAR=8.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 4882 | ▶ | grep defined, @{ $_[0]->[ _i ] || Graph::_empty_array() }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$_[0][3] || &Graph::_empty_array()
MC/DC0%0/2
$_[0][3] || &Graph::_empty_array()
$_[0][3]
&Graph::_empty_array()
Truth table33%1/3
A || B
A= $_[0][3]B= &Graph::_empty_array()
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 302 | ▶ | sub ids { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ids: called CC=2 SCAR=8.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | 302 | ▶ | values %{ $_[0]->[ _pi ] || Graph::_empty_array() }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$_[0][4] || &Graph::_empty_array()
MC/DC0%0/2
$_[0][4] || &Graph::_empty_array()
$_[0][4]
&Graph::_empty_array()
Truth table33%1/3
A || B
A= $_[0][4]B= &Graph::_empty_array()
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 1194 | ▶ | sub get_ids_by_paths { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_ids_by_paths: called CC=24 SCAR=31.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | 1194 | my ($f, $a, $pi, $m, $list, $ensure, $deep) = ( @{ $_[0] }[ _f, _arity, _pi ], @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 343 | 1194 | ▶ | $deep ||= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$deep ||= 0
MC/DC100%1/1
$deep ||= 0
$deep
Truth table100%2/2
A
A= $deep
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 1194 | my ($is_multi, $is_ref, $is_unord) = (map $f & $_, _MULTI, _REF, _UNORD); | |||||||||||||||||||||||||||||||||||||||||
| 345 | return map { # Fast path | ||||||||||||||||||||||||||||||||||||||||||
| 346 | 1194 | ▶ | my @ret = map { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$a and not $is_ref and $deep < 2
$a and not $is_ref
MC/DC100%3/3
$a and not $is_ref and $deep < 2
$a
not $is_ref
$deep < 2
Truth table100%4/4
A and not(B) and C
A= $aB= not $is_refC= $deep < 2
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 183 | ▶ | my $id = $pi->{ $a != 1 ? "@$_" : $_ }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 223 | ▶ | defined $id ? $id : | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | !$ensure ? return : | ||||||||||||||||||||||||||||||||||||||||||
| 350 | ($is_multi ? $m->set_path_by_multi_id($_, _GEN_ID) : $m->set_paths($_))[0]; | ||||||||||||||||||||||||||||||||||||||||||
| 351 | } $deep ? @$_ : $_; | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 170 | ▶ | $deep ? \@ret : @ret; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | } @$list if $a and !$is_ref and $deep < 2; | ||||||||||||||||||||||||||||||||||||||||||
| 354 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 355 | 1020 | my @ret = map { | |||||||||||||||||||||||||||||||||||||||||
| 356 | 1166 | my @ret2 = map { | |||||||||||||||||||||||||||||||||||||||||
| 357 | 1277 | my $k = $_; | |||||||||||||||||||||||||||||||||||||||||
| 358 | 1290 | ▶ | $k = __strval($k, $f) if $a == 1 && $is_ref && ref($k); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$a == 1 and $is_ref and ref $k
$a == 1 and $is_ref
MC/DC100%3/3
$a == 1 and $is_ref and ref $k
$a == 1
$is_ref
ref $k
Truth table100%4/4
A and B and C
A= $a == 1B= $is_refC= ref $k
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 1290 | ▶ | my $l = ($a == 0 && !$is_unord) ? join '|', map join(' ', sort @$_), @$k : $a == 1 ? "$k" : "@$k"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$a == 0 and not $is_unord
MC/DC100%2/2
$a == 0 and not $is_unord
$a == 0
not $is_unord
Truth table100%3/3
A and not(B)
A= $a == 0B= not $is_unord
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | 1290 | my $id = $pi->{ $l }; | |||||||||||||||||||||||||||||||||||||||||
| 361 | 1290 | ▶ | defined $id ? $id : | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | !$ensure ? return : | ||||||||||||||||||||||||||||||||||||||||||
| 363 | ($is_multi ? $m->set_path_by_multi_id($_, _GEN_ID) : $m->set_paths($_))[0]; | ||||||||||||||||||||||||||||||||||||||||||
| 364 | } $deep > 1 ? @$_ : $_; | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 1116 | ▶ | $deep > 1 ? \@ret2 : @ret2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | } $deep ? @$_ : $_; | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 1005 | ▶ | $deep ? \@ret : @ret; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 368 | } @$list; | ||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | 44 | ▶ | sub _paths_fromto { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_paths_fromto: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | 44 | my $offset = pop; | |||||||||||||||||||||||||||||||||||||||||
| 373 | 44 | my ($i, $map_x, @v) = ( @{ $_[0] }[ _i, $offset ], @_[1..$#_] ); | |||||||||||||||||||||||||||||||||||||||||
| 374 | 44 | ▶ | Graph::__carp_confess("undefined vertex") if grep !defined, @v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 44 | require Set::Object; | |||||||||||||||||||||||||||||||||||||||||
| 376 | 44 | ▶ | map $i->[ $_ ], Set::Object->new(map @$_, map values %{ $map_x->{ $_ } || _empty }, @v)->members; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$map_x->{$_} || &_empty()
MC/DC0%0/2
$map_x->{$_} || &_empty()
$map_x->{$_}
&_empty()
Truth table66%2/3
A || B
A= $map_x->{$_}B= &_empty()
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 27 | ▶ | sub paths_from { push @_, _s; goto &_paths_fromto } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
paths_from: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 17 | ▶ | sub paths_to { push @_, _p; goto &_paths_fromto } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
paths_to: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | 234 | ▶ | sub _cessors { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cessors: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | 234 | my $offset = pop; | |||||||||||||||||||||||||||||||||||||||||
| 383 | 234 | my ($map_x, @v) = ( @{ $_[0] }[ $offset ], @_[1..$#_] ); | |||||||||||||||||||||||||||||||||||||||||
| 384 | 234 | ▶ | Graph::__carp_confess("undefined vertex") if grep !defined, @v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 234 | require Set::Object; | |||||||||||||||||||||||||||||||||||||||||
| 386 | 234 | ▶ | Set::Object->new(map keys %{ $map_x->{ $_ } || _empty }, @v)->members; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$map_x->{$_} || &_empty()
MC/DC0%0/2
$map_x->{$_} || &_empty()
$map_x->{$_}
&_empty()
Truth table66%2/3
A || B
A= $map_x->{$_}B= &_empty()
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||
| 388 | 169 | ▶ | sub successors { push @_, _s; goto &_cessors } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
successors: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 65 | ▶ | sub predecessors { push @_, _p; goto &_cessors } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
predecessors: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 72 | ▶ | sub has_successor { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_successor: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | 72 | my ($map_s, $u, $v) = ( @{ $_[0] }[ _s ], @_[1, 2] ); | |||||||||||||||||||||||||||||||||||||||||
| 393 | 72 | ▶ | Graph::__carp_confess("undefined vertex") if grep !defined, $u, $v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | 72 | ▶ | exists ${ $map_s->{ $u } || _empty }{ $v }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$map_s->{$u} || &_empty()
MC/DC0%0/2
$map_s->{$u} || &_empty()
$map_s->{$u}
&_empty()
Truth table66%2/3
A || B
A= $map_s->{$u}B= &_empty()
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 2151 | ▶ | sub __strval { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__strval: called CC=4 SCAR=14.5
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 2151 | my ($k, $f) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 399 | 2151 | ▶ | return $k unless ref $k && ($f & _REF); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $k and $f & 8
MC/DC0%0/2
ref $k and $f & 8
ref $k
$f & 8
Truth table33%1/3
A and B
A= ref $kB= $f & 8
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | 2151 | ▶ | return "$k" if ($f & _STR); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | 2147 | require Scalar::Util; | |||||||||||||||||||||||||||||||||||||||||
| 402 | 2147 | Scalar::Util::refaddr($k); | |||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | 3623 | ▶ | sub __arg { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__arg: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | 3623 | my ($f, $a, $m, $k) = (@{ $_[0] }[ _f, _arity ], @_[0, 1]); | |||||||||||||||||||||||||||||||||||||||||
| 407 | 3623 | ▶ | Graph::__carp_confess(sprintf "arguments %d (%s) expected %d for\n".$m->stringify, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$a > 1 and @$k != $a
MC/DC0%0/2
$a > 1 and @$k != $a
$a > 1
@$k != $a
Truth table66%2/3
A and B
A= $a > 1B= @$k != $a
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | scalar @$k, "@$k", $a) | ||||||||||||||||||||||||||||||||||||||||||
| 409 | if $a > 1 and @$k != $a; | ||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 3 | ▶ | sub reindex { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reindex: called CC=6 SCAR=19.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | 3 | my ($f, $a, $i2p, $m) = (@{ $_[0] }[ _f, _arity, _i ], $_[0]); | |||||||||||||||||||||||||||||||||||||||||
| 414 | 3 | ▶ | my $is_ref = $a == 1 && ($f & _REF); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$a == 1 && $f & 8
MC/DC0%0/2
$a == 1 && $f & 8
$a == 1
$f & 8
Truth table33%1/3
A && B
A= $a == 1B= $f & 8
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | 3 | my $pi = $m->[ _pi ] = {}; | |||||||||||||||||||||||||||||||||||||||||
| 416 | 3 | for my $i ( 0..$#{ $i2p } ) { | |||||||||||||||||||||||||||||||||||||||||
| 417 | 4 | ▶ | next if !defined(my $k = $i2p->[ $i ]); # deleted | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 4 | ▶ | $k = __strval($k, $f) if $is_ref && ref($k); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$is_ref and ref $k
MC/DC0%0/2
$is_ref and ref $k
$is_ref
ref $k
Truth table33%1/3
A and B
A= $is_refB= ref $k
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | 4 | $pi->{ $k } = $i; | |||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | 84 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 424 | __END__ | ||||||||||||||||||||||||||||||||||||||||||