| 1 | # Copyright 2018, 2019, 2020, 2021 Kevin Ryde | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # This file is part of Graph-Maker-Other. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # This file is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # under the terms of the GNU General Public License as published by the Free | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # Software Foundation; either version 3, or (at your option) any later | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # version. | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # This file is distributed in the hope that it will be useful, but | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # for more details. | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # You should have received a copy of the GNU General Public License along | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # with Graph-Maker-Other. See the file COPYING. If not, see | ||||||||||||||||||||||||||||||||||||||||||
| 17 | # <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | package Graph::Maker::Catalans; | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use 5.004; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use constant 1.02; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use Carp 'croak'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use Graph::Maker; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use vars '$VERSION','@ISA'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | $VERSION = 19; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | @ISA = ('Graph::Maker'); | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | # uncomment this to run the ### lines | ||||||||||||||||||||||||||||||||||||||||||
| 32 | # use Smart::Comments; | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 244 | ▶ | sub _default_graph_maker { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_graph_maker: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | 244 | require Graph; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 244 | return Graph->new(@_); | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 244 | ▶ | sub _make_graph { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_make_graph: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 244 | my ($params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 41 | 244 | ▶ | my $graph_maker = delete($params->{'graph_maker'}) || \&_default_graph_maker; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $params->{'graph_maker'} || \&Graph::Maker::Catalans::_default_graph_maker
MC/DC0%0/1
delete $params->{'graph_maker'} || \&Graph::Maker::Catalans::_default_graph_maker
delete $params->{'graph_maker'}
Truth table50%1/2
A
A= delete $params->{'graph_maker'}
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 244 | return $graph_maker->(%$params); | |||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | # This finds the last run of 1s and moves the first of them up and the rest | ||||||||||||||||||||||||||||||||||||||||||
| 46 | # of them to the end and spread out. See Math::NumSeq::BalancedBinary for | ||||||||||||||||||||||||||||||||||||||||||
| 47 | # more description. | ||||||||||||||||||||||||||||||||||||||||||
| 48 | # | ||||||||||||||||||||||||||||||||||||||||||
| 49 | # M.C. Er, "Enumerating Ordered Trees Lexicographically", The Computer | ||||||||||||||||||||||||||||||||||||||||||
| 50 | # Journal, volume 28, number 5, 1985. Procedure GenSuc is this algorithm, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | # but applying all change once the run of 1s is located. Here the 1s are | ||||||||||||||||||||||||||||||||||||||||||
| 52 | # moved to the end while their extent is still being sought. | ||||||||||||||||||||||||||||||||||||||||||
| 53 | # | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 23095 | ▶ | sub _balanced_next { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_balanced_next: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 23095 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 56 | ### _balanced_next(): join('',@$aref) | ||||||||||||||||||||||||||||||||||||||||||
| 57 | 23095 | foreach my $i (reverse 1 .. $#$aref-1) { | |||||||||||||||||||||||||||||||||||||||||
| 58 | 52952 | ▶ | if ($aref->[$i]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | ### low 1 at: $i | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 23017 | my $o = 0; | |||||||||||||||||||||||||||||||||||||||||
| 61 | 23017 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 33780 | $aref->[$i--] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 33780 | ▶ | if ($i<0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | ### no more ... | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 239 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 33541 | $aref->[$o-=2] = 1; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } while ($aref->[$i]); | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 22778 | $aref->[$i] = 1; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 22778 | $aref->[$o] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 22778 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | ### no more ... | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 78 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | #---------------- | ||||||||||||||||||||||||||||||||||||||||||
| 79 | # Vertex Names | ||||||||||||||||||||||||||||||||||||||||||
| 80 | # | ||||||||||||||||||||||||||||||||||||||||||
| 81 | # Other possibilities | ||||||||||||||||||||||||||||||||||||||||||
| 82 | # N+1 elements with parens like 1(2(34))5 | ||||||||||||||||||||||||||||||||||||||||||
| 83 | # same as balanced with () for each elem ? | ||||||||||||||||||||||||||||||||||||||||||
| 84 | # | ||||||||||||||||||||||||||||||||||||||||||
| 85 | # one-sequence = position in balanced of each 1 | ||||||||||||||||||||||||||||||||||||||||||
| 86 | # zero-sequence = position in balanced of each 0 | ||||||||||||||||||||||||||||||||||||||||||
| 87 | # L-sequence = preorder, at each left child (internal or external), | ||||||||||||||||||||||||||||||||||||||||||
| 88 | # num externals below | ||||||||||||||||||||||||||||||||||||||||||
| 89 | # | ||||||||||||||||||||||||||||||||||||||||||
| 90 | # Zerling, rotation coding by rotate root until its subtree sizes are right, | ||||||||||||||||||||||||||||||||||||||||||
| 91 | # then recurse to left and then to right. Code as how many rotates applied. | ||||||||||||||||||||||||||||||||||||||||||
| 92 | # Write those from last to first, so first is on a left and so always 0. | ||||||||||||||||||||||||||||||||||||||||||
| 93 | # Regenerate by first to last code many right rotates. | ||||||||||||||||||||||||||||||||||||||||||
| 94 | # | ||||||||||||||||||||||||||||||||||||||||||
| 95 | # Description in Lucas, van Baronaigien, and Ruskey. | ||||||||||||||||||||||||||||||||||||||||||
| 96 | # Sequence c1 .. cn where sum(c1..cj) <= j. | ||||||||||||||||||||||||||||||||||||||||||
| 97 | # Start left path n vertices. | ||||||||||||||||||||||||||||||||||||||||||
| 98 | # For i=2..n, perform ci many right rotations at the root of T[1..i]. | ||||||||||||||||||||||||||||||||||||||||||
| 99 | # T[1..i] changes due to this. | ||||||||||||||||||||||||||||||||||||||||||
| 100 | # | ||||||||||||||||||||||||||||||||||||||||||
| 101 | # * figure 7 | ||||||||||||||||||||||||||||||||||||||||||
| 102 | # / \ Zerling 00 111 00 103 | ||||||||||||||||||||||||||||||||||||||||||
| 103 | # * * Weights 1,2,1,2,3,6,1,1,2,1 = Lweights | ||||||||||||||||||||||||||||||||||||||||||
| 104 | # / \ \ Distance 0,0,1,1,1,0,1,2,2,3 = Rdepths_inorder | ||||||||||||||||||||||||||||||||||||||||||
| 105 | # * * * | ||||||||||||||||||||||||||||||||||||||||||
| 106 | # / / \ | ||||||||||||||||||||||||||||||||||||||||||
| 107 | # * * * | ||||||||||||||||||||||||||||||||||||||||||
| 108 | # / | ||||||||||||||||||||||||||||||||||||||||||
| 109 | # * | ||||||||||||||||||||||||||||||||||||||||||
| 110 | # | ||||||||||||||||||||||||||||||||||||||||||
| 111 | # Or similar counts rotates but applied to the last edge of the tree. | ||||||||||||||||||||||||||||||||||||||||||
| 112 | # Becomes Rdepths, maybe. | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | my @pm_one = (-1, 1); | |||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 35701 | ▶ | sub _vertex_name_type_balanced { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vertex_name_type_balanced: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 35701 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 35701 | return @$aref; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 435 | ▶ | sub _vertex_name_type_balanced_postorder { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vertex_name_type_balanced_postorder: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 435 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 123 | ### _vertex_name_type_balanced_postorder(): join(',',@$aref) | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | # preorder 1 left 0 right 10 10 | ||||||||||||||||||||||||||||||||||||||||||
| 126 | # postorder left 1 right 0 1 10 0 | ||||||||||||||||||||||||||||||||||||||||||
| 127 | # | ||||||||||||||||||||||||||||||||||||||||||
| 128 | # 0 = end of depth d | ||||||||||||||||||||||||||||||||||||||||||
| 129 | # emit 1, remember 0 for end of depth d-1 | ||||||||||||||||||||||||||||||||||||||||||
| 130 | # 1 = start of new depth | ||||||||||||||||||||||||||||||||||||||||||
| 131 | # | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 435 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 435 | my @pending = (0); | |||||||||||||||||||||||||||||||||||||||||
| 134 | 435 | foreach my $bit (@$aref) { | |||||||||||||||||||||||||||||||||||||||||
| 135 | ### at: "bit $bit pending ".join(',',@pending)." ret=".join('',@ret) | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 4632 | ▶ | if ($bit) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 2316 | push @pending, 0; | |||||||||||||||||||||||||||||||||||||||||
| 138 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 139 | ### end: "emit pending 0s $pending[-1], and 1" | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 2316 | push @ret, (0) x pop @pending, 1; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 2316 | $pending[-1]++; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | ### final pending: join(',',@pending) | ||||||||||||||||||||||||||||||||||||||||||
| 145 | ### assert: scalar(@pending)==1 | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 435 | push @ret, (0) x $pending[0]; | |||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | ### ret: join('',@ret) | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 435 | return @ret; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | # form used by Sapounakis et al for filling | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 2092 | ▶ | sub _vertex_name_type_run1s { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vertex_name_type_run1s: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 2092 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 2092 | my $r = 0; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 2092 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 157 | 2092 | foreach my $bit (@$aref) { | |||||||||||||||||||||||||||||||||||||||||
| 158 | 31334 | ▶ | if ($bit) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 15667 | $r++; | |||||||||||||||||||||||||||||||||||||||||
| 160 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 15667 | push @ret, $r; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 15667 | $r = 0; | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 2092 | return @ret; | |||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | # Knuth volume 4A section 7.2.1.6 after algorithm P at equation (6), which | ||||||||||||||||||||||||||||||||||||||||||
| 169 | # is in pre-fascicle 4A | ||||||||||||||||||||||||||||||||||||||||||
| 170 | # http://www-cs-faculty.stanford.edu/~knuth/fasc4a.ps.gz draft of section | ||||||||||||||||||||||||||||||||||||||||||
| 171 | # 7.2.1.6 page 3, run length encode 0-bits | ||||||||||||||||||||||||||||||||||||||||||
| 172 | # | ||||||||||||||||||||||||||||||||||||||||||
| 173 | # d1 d1 dn | ||||||||||||||||||||||||||||||||||||||||||
| 174 | # ( ) ( ) ... ( ) | ||||||||||||||||||||||||||||||||||||||||||
| 175 | # | ||||||||||||||||||||||||||||||||||||||||||
| 176 | # where )^d[i] means d[i] many closes at that point. Such a run is after | ||||||||||||||||||||||||||||||||||||||||||
| 177 | # each open, and can have d[i]=0 for no closes there. | ||||||||||||||||||||||||||||||||||||||||||
| 178 | # | ||||||||||||||||||||||||||||||||||||||||||
| 179 | # Per exercise 30 in the same section (draft page 35): | ||||||||||||||||||||||||||||||||||||||||||
| 180 | # An ordered forest childful is where d[i]=0, for a new left descent. | ||||||||||||||||||||||||||||||||||||||||||
| 181 | # childless is where d[i]!=0, for step up to higher sibling. | ||||||||||||||||||||||||||||||||||||||||||
| 182 | # | ||||||||||||||||||||||||||||||||||||||||||
| 183 | # Other vertex name forms in Knuth: | ||||||||||||||||||||||||||||||||||||||||||
| 184 | # z1,z2,...,zn positions 0 to 2n-1 of the 1s. | ||||||||||||||||||||||||||||||||||||||||||
| 185 | # run1s[i] = z[i+1] - z[i] - 1 | ||||||||||||||||||||||||||||||||||||||||||
| 186 | # | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 2070 | ▶ | sub _vertex_name_type_run0s { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vertex_name_type_run0s: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 2070 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 189 | 2070 | my $r = 0; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 2070 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 2070 | foreach my $bit (reverse @$aref) { | |||||||||||||||||||||||||||||||||||||||||
| 192 | 31154 | ▶ | if ($bit) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 15577 | push @ret, $r; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 15577 | $r = 0; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 15577 | $r++; | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 2070 | return reverse @ret; | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 5927 | ▶ | sub _vertex_name_type_Ldepths { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vertex_name_type_Ldepths: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 5927 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 5927 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 5927 | my $d = 0; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 5927 | foreach my $bit (@$aref) { | |||||||||||||||||||||||||||||||||||||||||
| 207 | 81202 | ▶ | if ($bit) { push @ret, $d; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 81202 | $d += $pm_one[$bit]; | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 5927 | return @ret; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 2276 | ▶ | sub _vertex_name_type_Ldepths_inorder { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vertex_name_type_Ldepths_inorder: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 2276 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 215 | # This code uses the form noted in the POD, at each 0 how many unclosed 1s | ||||||||||||||||||||||||||||||||||||||||||
| 216 | # precede, with the 0 itself counted as a closing, so done after pm_one. | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 2276 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 218 | 2276 | my $d = 0; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 2276 | foreach my $bit (@$aref) { | |||||||||||||||||||||||||||||||||||||||||
| 220 | 33350 | $d += $pm_one[$bit]; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 33350 | ▶ | unless ($bit) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 16675 | push @ret, $d; # at each 0, num unclosed 0s after, not incl self | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 2276 | return @ret; | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 225 | ▶ | sub _vertex_name_type_Bdepths_inorder { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vertex_name_type_Bdepths_inorder: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 225 | return _vertex_name_type_Rdepths_inorder(@_,1); | |||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 451 | ▶ | sub _vertex_name_type_Rdepths_inorder { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vertex_name_type_Rdepths_inorder: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 451 | my ($aref, $l) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 233 | # $l = 1 if count left steps too, giving Bdepths | ||||||||||||||||||||||||||||||||||||||||||
| 234 | # = 0 if no count left step, giving Rdepths | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 451 | ▶ | $l ||= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$l ||= 0
MC/DC100%1/1
$l ||= 0
$l
Truth table100%2/2
A
A= $l
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | ### _vertex_name_type_Rdepths(): "l=$l ".join('',@$aref) | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 451 | my @pos = (0); | |||||||||||||||||||||||||||||||||||||||||
| 238 | 451 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 239 | 451 | my $d = 0; | |||||||||||||||||||||||||||||||||||||||||
| 240 | 451 | foreach my $bit (@$aref) { | |||||||||||||||||||||||||||||||||||||||||
| 241 | ### at: "bit $bit d=$d pos ".join(',',@pos) | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 4696 | ▶ | if ($bit) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 2348 | push @pos, $pos[-1]; # copy | |||||||||||||||||||||||||||||||||||||||||
| 244 | 2348 | $d += $l; | |||||||||||||||||||||||||||||||||||||||||
| 245 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 2348 | $d -= $l; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 2348 | pop @pos; # backtrack and go right | |||||||||||||||||||||||||||||||||||||||||
| 248 | 2348 | push @ret, ($pos[-1]++) + $d; | |||||||||||||||||||||||||||||||||||||||||
| 249 | ### ret: $ret[-1] | ||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | ### return: join(',',@ret) | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 451 | return @ret; | |||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 223 | ▶ | sub _vertex_name_type_Rdepths_postorder { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vertex_name_type_Rdepths_postorder: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 223 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 258 | ### _vertex_name_type_Rdepths_postorder(): join(',',@$aref) | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | # $pending[] is how many right descents above the present vertex. | ||||||||||||||||||||||||||||||||||||||||||
| 261 | # Preorder balanced binary is then: | ||||||||||||||||||||||||||||||||||||||||||
| 262 | # 1 = internal vertex, descend to the left, so new 0 many rights. | ||||||||||||||||||||||||||||||||||||||||||
| 263 | # 0 = external vertex | ||||||||||||||||||||||||||||||||||||||||||
| 264 | # pop @pending for how many rights to go up, each of them is a depth | ||||||||||||||||||||||||||||||||||||||||||
| 265 | # then next descent is a right so increment now top $pending[-1] | ||||||||||||||||||||||||||||||||||||||||||
| 266 | # $d = right steps depth of current internal vertex | ||||||||||||||||||||||||||||||||||||||||||
| 267 | # Similar to _vertex_name_type_balanced_postorder(), but there just pushing | ||||||||||||||||||||||||||||||||||||||||||
| 268 | # all 1s for the pop @pending rights to go up, not depths. | ||||||||||||||||||||||||||||||||||||||||||
| 269 | # | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 223 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 271 | 223 | my @pending = (0); | |||||||||||||||||||||||||||||||||||||||||
| 272 | 223 | my $d = 0; | |||||||||||||||||||||||||||||||||||||||||
| 273 | 223 | foreach my $bit (@$aref) { | |||||||||||||||||||||||||||||||||||||||||
| 274 | ### at: "bit $bit d=$d pending ".join(',',@pending) | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 2322 | ▶ | if ($bit) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 1161 | push @pending, 0; | |||||||||||||||||||||||||||||||||||||||||
| 277 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 278 | ### end: "emit $pending[-1] many" | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 1161 | my $new_d = $d - pop @pending; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 1161 | push @ret, reverse $new_d .. $d-1; | |||||||||||||||||||||||||||||||||||||||||
| 281 | 1161 | $d = $new_d + 1; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 1161 | $pending[-1]++; | |||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | ### end pending: join('',@pending) | ||||||||||||||||||||||||||||||||||||||||||
| 286 | ### end ret: join('',@ret) | ||||||||||||||||||||||||||||||||||||||||||
| 287 | ### $d | ||||||||||||||||||||||||||||||||||||||||||
| 288 | ### assert: @pending==1 | ||||||||||||||||||||||||||||||||||||||||||
| 289 | 223 | return @ret, reverse 0 .. $pending[0]-1; | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 6757 | ▶ | sub _vertex_name_type_vpar { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vertex_name_type_vpar: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 6757 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 294 | 6757 | my @vpar; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 6757 | my $p = 0; | |||||||||||||||||||||||||||||||||||||||||
| 296 | 6757 | foreach my $bit (@$aref) { | |||||||||||||||||||||||||||||||||||||||||
| 297 | 89354 | ▶ | if ($bit) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 44677 | push @vpar, $p; | |||||||||||||||||||||||||||||||||||||||||
| 299 | 44677 | $p = scalar @vpar; | |||||||||||||||||||||||||||||||||||||||||
| 300 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 44677 | $p = $vpar[$p-1]; | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 6757 | return @vpar; | |||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 2255 | ▶ | sub _vertex_name_type_vpar_postorder { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vertex_name_type_vpar_postorder: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | 2255 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 308 | ### _vertex_name_type_vpar_postorder(): join('',@$aref) | ||||||||||||||||||||||||||||||||||||||||||
| 309 | 2255 | my @vpar; | |||||||||||||||||||||||||||||||||||||||||
| 310 | 2255 | my $p = 0; | |||||||||||||||||||||||||||||||||||||||||
| 311 | 2255 | my $v = scalar(@$aref) >> 1; | |||||||||||||||||||||||||||||||||||||||||
| 312 | 2255 | foreach my $bit (reverse @$aref) { | |||||||||||||||||||||||||||||||||||||||||
| 313 | 33206 | ▶ | if ($bit) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 16603 | $p = $vpar[$p-1]; | |||||||||||||||||||||||||||||||||||||||||
| 315 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 16603 | $vpar[$v-1] = $p; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 16603 | $p = $v; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 16603 | $v--; | |||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | ### @vpar | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 2255 | return @vpar; | |||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | 3558 | ▶ | sub _vertex_name_type_Lweights { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vertex_name_type_Lweights: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 3558 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 3558 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 328 | 3558 | my @sizes = (1); | |||||||||||||||||||||||||||||||||||||||||
| 329 | 3558 | foreach my $bit (@$aref) { | |||||||||||||||||||||||||||||||||||||||||
| 330 | ### at: "bit $bit sizes ".join(',',@sizes) | ||||||||||||||||||||||||||||||||||||||||||
| 331 | 47336 | ▶ | if ($bit) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | 23668 | push @sizes, 1; | |||||||||||||||||||||||||||||||||||||||||
| 333 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 23668 | my $size = pop @sizes; | |||||||||||||||||||||||||||||||||||||||||
| 335 | 23668 | push @ret, $size; | |||||||||||||||||||||||||||||||||||||||||
| 336 | 23668 | $sizes[-1] += $size; | |||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | 3558 | return @ret; | |||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 2260 | ▶ | sub _vertex_name_type_Rweights { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vertex_name_type_Rweights: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | 2260 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 343 | ### _vertex_name_type_Rweights(): join('',@$aref) | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 2260 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 345 | 2260 | my @Rweights = (1); | |||||||||||||||||||||||||||||||||||||||||
| 346 | 2260 | foreach my $bit (reverse @$aref) { | |||||||||||||||||||||||||||||||||||||||||
| 347 | ### at: "bit $bit Rweights ".join(',',@Rweights) | ||||||||||||||||||||||||||||||||||||||||||
| 348 | 33248 | ▶ | if ($bit) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | ### add to above ... | ||||||||||||||||||||||||||||||||||||||||||
| 350 | 16624 | my $Rweights = pop @Rweights; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 16624 | $Rweights[-1] += $Rweights; | |||||||||||||||||||||||||||||||||||||||||
| 352 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 353 | ### push ret: $Rweights[-1] | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 16624 | push @ret, $Rweights[-1]; | |||||||||||||||||||||||||||||||||||||||||
| 355 | 16624 | push @Rweights, 1; | |||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 358 | ### return: join(',',reverse @ret) | ||||||||||||||||||||||||||||||||||||||||||
| 359 | 2260 | return reverse @ret; | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | # Adaricheva arxiv 1101.1536v3 "right bracketing" is parens in postorder | ||||||||||||||||||||||||||||||||||||||||||
| 363 | # balanced. | ||||||||||||||||||||||||||||||||||||||||||
| 364 | # | ||||||||||||||||||||||||||||||||||||||||||
| 365 | # * ((01)(23)) | ||||||||||||||||||||||||||||||||||||||||||
| 366 | # / \ 0(1)(2(3)) | ||||||||||||||||||||||||||||||||||||||||||
| 367 | # * * preorder 110010 | ||||||||||||||||||||||||||||||||||||||||||
| 368 | # / \ / \ postorder 101100 | ||||||||||||||||||||||||||||||||||||||||||
| 369 | # 0 1 2 3 ()(()) | ||||||||||||||||||||||||||||||||||||||||||
| 370 | # | ||||||||||||||||||||||||||||||||||||||||||
| 371 | # * ((ab)((cd)e)) | ||||||||||||||||||||||||||||||||||||||||||
| 372 | # / \ F = 4,2,4,4 | ||||||||||||||||||||||||||||||||||||||||||
| 373 | # * * preorder 11001100 | ||||||||||||||||||||||||||||||||||||||||||
| 374 | # / \ / \ postorder 10 110100 | ||||||||||||||||||||||||||||||||||||||||||
| 375 | # a b * e () (()()) | ||||||||||||||||||||||||||||||||||||||||||
| 376 | # / \ a(b)(c(d)(e)) | ||||||||||||||||||||||||||||||||||||||||||
| 377 | # c d 1 2 3 4 | ||||||||||||||||||||||||||||||||||||||||||
| 378 | # 2 4 3 4 | ||||||||||||||||||||||||||||||||||||||||||
| 379 | # | ||||||||||||||||||||||||||||||||||||||||||
| 380 | # * ((a((bc)d))e) | ||||||||||||||||||||||||||||||||||||||||||
| 381 | # / \ E = 3,2,3,4 | ||||||||||||||||||||||||||||||||||||||||||
| 382 | # * e preorder 11011000 | ||||||||||||||||||||||||||||||||||||||||||
| 383 | # / \ (()(())) | ||||||||||||||||||||||||||||||||||||||||||
| 384 | # a * postorder 11010010 | ||||||||||||||||||||||||||||||||||||||||||
| 385 | # / \ (()())() | ||||||||||||||||||||||||||||||||||||||||||
| 386 | # * d a(b(c)(d))(e) | ||||||||||||||||||||||||||||||||||||||||||
| 387 | # / \ 1 2 3 4 | ||||||||||||||||||||||||||||||||||||||||||
| 388 | # b c 3 2 3 4 | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | # =head3 Bracketing | ||||||||||||||||||||||||||||||||||||||||||
| 391 | # | ||||||||||||||||||||||||||||||||||||||||||
| 392 | # Option C<vertex_name_type =E<gt> 'bracketing'> is parenthesized terms like | ||||||||||||||||||||||||||||||||||||||||||
| 393 | # "((1,2)3)". Each external vertex is numbered 1 to N+1 left to right. | ||||||||||||||||||||||||||||||||||||||||||
| 394 | # Each internal vertex is parens "(left right)". A comma (L</Comma> below) | ||||||||||||||||||||||||||||||||||||||||||
| 395 | # is between numbers when a vertex has two externals (ie. is a leaf). | ||||||||||||||||||||||||||||||||||||||||||
| 396 | # | ||||||||||||||||||||||||||||||||||||||||||
| 397 | # There are N pairs of parens. When N=0 there are no parens and the sole | ||||||||||||||||||||||||||||||||||||||||||
| 398 | # vertex name is "1". N=1 is one pair and sole vertex name "(1,2)". | ||||||||||||||||||||||||||||||||||||||||||
| 399 | # | ||||||||||||||||||||||||||||||||||||||||||
| 400 | # Option C<vertex_name_type =E<gt> 'bracketing_reduced'> removes paren pairs | ||||||||||||||||||||||||||||||||||||||||||
| 401 | # containing the final N+1 external. For example | ||||||||||||||||||||||||||||||||||||||||||
| 402 | # | ||||||||||||||||||||||||||||||||||||||||||
| 403 | # (1((2,3)(4,5))) bracketing | ||||||||||||||||||||||||||||||||||||||||||
| 404 | # 1(2,3)4,5 bracketing_reduced | ||||||||||||||||||||||||||||||||||||||||||
| 405 | # | ||||||||||||||||||||||||||||||||||||||||||
| 406 | # This reduction is unambiguous. The reduction leaves consecutive terms "T1 | ||||||||||||||||||||||||||||||||||||||||||
| 407 | # T2 ... Tk". Each is either an external, or a parenthesized internal. The | ||||||||||||||||||||||||||||||||||||||||||
| 408 | # full bracketing has parens T1..Tk then T2..Tk then T3..Tk etc. | ||||||||||||||||||||||||||||||||||||||||||
| 409 | # | ||||||||||||||||||||||||||||||||||||||||||
| 410 | # In terms of the binary tree, each of these T is a left child subtree of | ||||||||||||||||||||||||||||||||||||||||||
| 411 | # the rightmost arm descents. | ||||||||||||||||||||||||||||||||||||||||||
| 412 | # | ||||||||||||||||||||||||||||||||||||||||||
| 413 | # cf | ||||||||||||||||||||||||||||||||||||||||||
| 414 | # Tamari and Huang, r.b and g.b. | ||||||||||||||||||||||||||||||||||||||||||
| 415 | # | ||||||||||||||||||||||||||||||||||||||||||
| 416 | # UNDOCUMENTED | ||||||||||||||||||||||||||||||||||||||||||
| 417 | 120 | ▶ | sub _vertex_name_type_bracketing_reduced { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vertex_name_type_bracketing_reduced: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 120 | return _vertex_name_type_bracketing(@_,1); | |||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | # FIXME: Want outer parens so N=0 is "1" and N=1 is (12) ? | ||||||||||||||||||||||||||||||||||||||||||
| 421 | # Omitting outermost would be inconsistent between N=0 and N=1. | ||||||||||||||||||||||||||||||||||||||||||
| 422 | # Including means 2N parens. | ||||||||||||||||||||||||||||||||||||||||||
| 423 | # | ||||||||||||||||||||||||||||||||||||||||||
| 424 | # UNDOCUMENTED | ||||||||||||||||||||||||||||||||||||||||||
| 425 | 126 | ▶ | sub _vertex_name_type_bracketing { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_vertex_name_type_bracketing: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 126 | my ($aref,$reduced) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 427 | ### _vertex_name_type_bracketing(): join('',@$aref) | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | 126 | my @ret; # array of strings to return | |||||||||||||||||||||||||||||||||||||||||
| 430 | 126 | my $ret = ''; # current string being built | |||||||||||||||||||||||||||||||||||||||||
| 431 | 126 | my $leaf = 1; # leaf vertex number 1 .. N+1 | |||||||||||||||||||||||||||||||||||||||||
| 432 | 126 | my $d = 0; # Ldepth = how many left steps down = excess 1s over 0s | |||||||||||||||||||||||||||||||||||||||||
| 433 | 126 | my $sep; # 1 = prev was number so want separator if next is a number | |||||||||||||||||||||||||||||||||||||||||
| 434 | 126 | my @closes = (0,0); | |||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 126 | foreach my $bit (@$aref, 0) { | |||||||||||||||||||||||||||||||||||||||||
| 437 | ### at: "bit $bit ret=$ret" | ||||||||||||||||||||||||||||||||||||||||||
| 438 | 1300 | ▶ | if ($bit) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | 587 | ▶ | if ($d || !$reduced) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$d or not $reduced
MC/DC100%2/2
$d or not $reduced
$d
not $reduced
Truth table100%3/3
A or not(B)
A= $dB= not $reduced
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 337 | $ret .= '('; | |||||||||||||||||||||||||||||||||||||||||
| 441 | 337 | $sep = 0; | |||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||
| 443 | 587 | push @closes, 0; | |||||||||||||||||||||||||||||||||||||||||
| 444 | 587 | $d++; | |||||||||||||||||||||||||||||||||||||||||
| 445 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 446 | 713 | ▶ | if ($sep) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | 237 | push @ret, $ret; | |||||||||||||||||||||||||||||||||||||||||
| 448 | 237 | $ret = ''; | |||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 450 | 713 | $ret .= $leaf++; | |||||||||||||||||||||||||||||||||||||||||
| 451 | 713 | $sep = 1; | |||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 713 | $d--; | |||||||||||||||||||||||||||||||||||||||||
| 454 | 713 | ▶ | unless ($reduced && $d < 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$reduced and $d < 0
MC/DC100%2/2
$reduced and $d < 0
$reduced
$d < 0
Truth table100%3/3
A and B
A= $reducedB= $d < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | 593 | my $closes = pop @closes; | |||||||||||||||||||||||||||||||||||||||||
| 456 | 593 | foreach (1 .. $closes) { | |||||||||||||||||||||||||||||||||||||||||
| 457 | 337 | $ret .= ')'; | |||||||||||||||||||||||||||||||||||||||||
| 458 | 337 | $sep = 0; | |||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||
| 460 | 593 | $closes[-1]++; | |||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||
| 464 | 126 | return @ret, $ret; | |||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | #--------- | ||||||||||||||||||||||||||||||||||||||||||
| 468 | # Rotate | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | 9647 | ▶ | sub _rotate_at { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rotate_at: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 471 | 9647 | my ($aref, $i) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 472 | ### assert: 1 <= $i | ||||||||||||||||||||||||||||||||||||||||||
| 473 | ### assert: $i <= $#$aref-1 | ||||||||||||||||||||||||||||||||||||||||||
| 474 | ### assert: $aref->[$i] == 0 | ||||||||||||||||||||||||||||||||||||||||||
| 475 | ### assert: $aref->[$i+1] == 1 | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 9647 | my @new_array = @$aref; | |||||||||||||||||||||||||||||||||||||||||
| 478 | 9647 | my $d = 0; | |||||||||||||||||||||||||||||||||||||||||
| 479 | 9647 | ▶ | while ($d += $pm_one[ $new_array[$i+1] = $new_array[$i] ]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 480 | 27497 | $i--; | |||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||
| 482 | 9647 | return \@new_array; | |||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | 1 | ▶ | use constant _rel_type_name_rotate => 'Rotate'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | 1953 | ▶ | sub _rel_type_rotate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rel_type_rotate: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 487 | 1953 | my ($aref, $one) = @_; # $one meaning rotate_first only | |||||||||||||||||||||||||||||||||||||||||
| 488 | 1953 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 489 | 1953 | foreach my $i (1 .. $#$aref-1) { | |||||||||||||||||||||||||||||||||||||||||
| 490 | 19499 | ▶ | if (!$aref->[$i] && $aref->[$i+1]) { # want 01 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $aref->[$i] and $$aref[$i + 1]
MC/DC100%2/2
not $aref->[$i] and $$aref[$i + 1]
not $aref->[$i]
$$aref[$i + 1]
Truth table100%3/3
not(A) and B
A= not $aref->[$i]B= $$aref[$i + 1]
| |||||||||||||||||||||||||||||||||||||||||||
| 491 | 4898 | push @ret, _rotate_at($aref, $i); | |||||||||||||||||||||||||||||||||||||||||
| 492 | 4898 | ▶ | last if $one; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 495 | 1953 | return @ret; | |||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | 1 | ▶ | use constant _rel_type_name_rotate_first => 'Rotate First'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 499 | 79 | ▶ | sub _rel_type_rotate_first { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rel_type_rotate_first: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | 79 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 501 | 79 | _rel_type_rotate($aref,1); | |||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | 1 | ▶ | use constant _rel_type_name_rotate_last => 'Rotate Last'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 505 | 631 | ▶ | sub _rel_type_rotate_last { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rel_type_rotate_last: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 506 | 631 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 507 | 631 | foreach my $i (reverse 1 .. $#$aref-1) { | |||||||||||||||||||||||||||||||||||||||||
| 508 | 2349 | ▶ | if (!$aref->[$i] && $aref->[$i+1]) { # last 01 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $aref->[$i] and $$aref[$i + 1]
MC/DC100%2/2
not $aref->[$i] and $$aref[$i + 1]
not $aref->[$i]
$$aref[$i + 1]
Truth table100%3/3
not(A) and B
A= not $aref->[$i]B= $$aref[$i + 1]
| |||||||||||||||||||||||||||||||||||||||||||
| 509 | 622 | return _rotate_at($aref, $i); | |||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||
| 512 | 9 | return (); | |||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||
| 515 | 1 | ▶ | use constant _rel_type_name_rotate_rightarm => 'Rotate Right Arm'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 516 | 2131 | ▶ | sub _rel_type_rotate_rightarm { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rel_type_rotate_rightarm: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 517 | 2131 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 518 | 2131 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 519 | 2131 | my $d = 1; | |||||||||||||||||||||||||||||||||||||||||
| 520 | 2131 | foreach my $i (1 .. $#$aref-1) { | |||||||||||||||||||||||||||||||||||||||||
| 521 | 22920 | $d += $pm_one[$aref->[$i]]; | |||||||||||||||||||||||||||||||||||||||||
| 522 | 22920 | ▶ | unless ($aref->[$i] || $d) { # at bit=0 and d==0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$aref->[$i] or $d
MC/DC100%2/2
$aref->[$i] or $d
$aref->[$i]
$d
Truth table100%3/3
A or B
A= $aref->[$i]B= $d
| |||||||||||||||||||||||||||||||||||||||||||
| 523 | 2706 | push @ret, _rotate_at($aref, $i); | |||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||
| 526 | 2131 | return @ret; | |||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | # 11 1 A 0 1 B 0 C 1 1 A 0 B 0 C | ||||||||||||||||||||||||||||||||||||||||||
| 530 | # ^^^^^ ^^^^^ | ||||||||||||||||||||||||||||||||||||||||||
| 531 | # | ||||||||||||||||||||||||||||||||||||||||||
| 532 | # 11010010 | ||||||||||||||||||||||||||||||||||||||||||
| 533 | # ^^ | ||||||||||||||||||||||||||||||||||||||||||
| 534 | # ^^ | ||||||||||||||||||||||||||||||||||||||||||
| 535 | 1 | ▶ | use constant _rel_type_name_rotate_leftarm => 'Rotate Left Arm'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 536 | 651 | ▶ | sub _rel_type_rotate_leftarm { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rel_type_rotate_leftarm: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 537 | 651 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 538 | 651 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 539 | 651 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||
| 540 | 651 | ▶ | for ( ; $i <= $#$aref; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 541 | 2122 | ▶ | unless ($aref->[$i]) { last; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||
| 543 | 651 | my $lefts = $i; # how many initial 1s | |||||||||||||||||||||||||||||||||||||||||
| 544 | ### $lefts | ||||||||||||||||||||||||||||||||||||||||||
| 545 | 651 | my $d = $i; | |||||||||||||||||||||||||||||||||||||||||
| 546 | 651 | ▶ | for ( ; $i < $#$aref; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 547 | ### at: "i=$i d=$d" | ||||||||||||||||||||||||||||||||||||||||||
| 548 | 6206 | $d += $pm_one[$aref->[$i]]; | |||||||||||||||||||||||||||||||||||||||||
| 549 | 6206 | ▶ | if ($d < $lefts) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | ### at lefts level: $lefts | ||||||||||||||||||||||||||||||||||||||||||
| 551 | ### assert: ! $aref->[$i] | ||||||||||||||||||||||||||||||||||||||||||
| 552 | 1267 | ▶ | if ($aref->[$i+1]) { # 01 for rotate | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 553 | 826 | push @ret, _rotate_at($aref, $i); | |||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||
| 555 | 1267 | ▶ | $lefts-- or last; # stop when back to zero line | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||
| 558 | 651 | return @ret; | |||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | # A-empty and 101 is not allowed to be first gives disconnected with N | ||||||||||||||||||||||||||||||||||||||||||
| 562 | # predecessorless. | ||||||||||||||||||||||||||||||||||||||||||
| 563 | # | ||||||||||||||||||||||||||||||||||||||||||
| 564 | 1 | ▶ | use constant _rel_type_name_rotate_Aempty => 'Rotate A-Empty'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 565 | 626 | ▶ | sub _rel_type_rotate_Aempty { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rel_type_rotate_Aempty: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 566 | 626 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 567 | # from 1 A 0 1 B 0 C from 1 0 1 B 0 C | ||||||||||||||||||||||||||||||||||||||||||
| 568 | # to 1 1 A 0 B 0 C to 1 1 0 B 0 C | ||||||||||||||||||||||||||||||||||||||||||
| 569 | # ^^^^^ | ||||||||||||||||||||||||||||||||||||||||||
| 570 | 626 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 571 | 626 | foreach my $i (0 .. $#$aref-2) { | |||||||||||||||||||||||||||||||||||||||||
| 572 | 6912 | ▶ | if ($aref->[$i] && !$aref->[$i+1] && $aref->[$i+2]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$aref->[$i] and not $$aref[$i + 1] and $$aref[$i + 2]
$aref->[$i] and not $$aref[$i + 1]
MC/DC100%3/3
$aref->[$i] and not $$aref[$i + 1] and $$aref[$i + 2]
$aref->[$i]
not $$aref[$i + 1]
$$aref[$i + 2]
Truth table100%4/4
A and not(B) and C
A= $aref->[$i]B= not $$aref[$i + 1]C= $$aref[$i + 2]
| |||||||||||||||||||||||||||||||||||||||||||
| 573 | 1078 | my @new_array = @$aref; | |||||||||||||||||||||||||||||||||||||||||
| 574 | 1078 | $new_array[$i+1] = 1; | |||||||||||||||||||||||||||||||||||||||||
| 575 | 1078 | $new_array[$i+2] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 576 | 1078 | push @ret, \@new_array; | |||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||
| 579 | 626 | return @ret; | |||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||
| 582 | 1 | ▶ | use constant _rel_type_name_rotate_Bempty => 'Rotate B-Empty'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 583 | 413 | ▶ | sub _rel_type_rotate_Bempty { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rel_type_rotate_Bempty: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 584 | 413 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 585 | # 1 A 0 1 B 0 C 1 A 0 1 0 C | ||||||||||||||||||||||||||||||||||||||||||
| 586 | # ^^^^^ | ||||||||||||||||||||||||||||||||||||||||||
| 587 | 413 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 588 | 413 | foreach my $i (1 .. $#$aref-2) { | |||||||||||||||||||||||||||||||||||||||||
| 589 | 3223 | ▶ | if (!$aref->[$i] && $aref->[$i+1] && !$aref->[$i+2]) { # 010 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
not $aref->[$i] and $$aref[$i + 1] and not $$aref[$i + 2]
not $aref->[$i] and $$aref[$i + 1]
MC/DC100%3/3
not $aref->[$i] and $$aref[$i + 1] and not $$aref[$i + 2]
not $aref->[$i]
$$aref[$i + 1]
not $$aref[$i + 2]
Truth table100%4/4
not(A) and B and not(C)
A= not $aref->[$i]B= $$aref[$i + 1]C= not $$aref[$i + 2]
| |||||||||||||||||||||||||||||||||||||||||||
| 590 | 591 | push @ret, _rotate_at($aref, $i); | |||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||
| 593 | 413 | return @ret; | |||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||
| 596 | 1 | ▶ | use constant _rel_type_name_rotate_Cempty => 'Rotate C-Empty'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 597 | 5 | ▶ | sub _rel_type_rotate_Cempty { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rel_type_rotate_Cempty: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 598 | 5 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 599 | # i | ||||||||||||||||||||||||||||||||||||||||||
| 600 | # from 1 A 0 1 B 0 C 1 A 0 1 B 0 (0 or end) | ||||||||||||||||||||||||||||||||||||||||||
| 601 | # to 1 1 A 0 B 0 C 1 1 A 0 B 0 | ||||||||||||||||||||||||||||||||||||||||||
| 602 | 5 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 603 | 5 | foreach my $i (1 .. $#$aref-1) { | |||||||||||||||||||||||||||||||||||||||||
| 604 | 20 | ▶ | if (!$aref->[$i] && $aref->[$i+1]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $aref->[$i] and $$aref[$i + 1]
MC/DC100%2/2
not $aref->[$i] and $$aref[$i + 1]
not $aref->[$i]
$$aref[$i + 1]
Truth table100%3/3
not(A) and B
A= not $aref->[$i]B= $$aref[$i + 1]
| |||||||||||||||||||||||||||||||||||||||||||
| 605 | 5 | my $d = 1; | |||||||||||||||||||||||||||||||||||||||||
| 606 | 5 | my $j = _balanced_end($aref,$i+1) + 1; | |||||||||||||||||||||||||||||||||||||||||
| 607 | 5 | ▶ | unless ($aref->[$j]) { # not a following 1, must either 0 or end | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 608 | 4 | push @ret, _rotate_at($aref, $i); | |||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||
| 612 | 5 | return @ret; | |||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | # $aref is an arrayref to balanced binary 0s and 1s. | ||||||||||||||||||||||||||||||||||||||||||
| 616 | # $i is index into $aref of a 1. | ||||||||||||||||||||||||||||||||||||||||||
| 617 | # Return the index of the matching closing 0 for that 1. | ||||||||||||||||||||||||||||||||||||||||||
| 618 | 1738 | ▶ | sub _balanced_end { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_balanced_end: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 619 | 1738 | my ($aref, $i) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 620 | ### assert: $aref->[$i] == 1 | ||||||||||||||||||||||||||||||||||||||||||
| 621 | 1738 | my $d = 1; | |||||||||||||||||||||||||||||||||||||||||
| 622 | 1738 | ▶ | while ($d += $pm_one[$aref->[++$i]]) {} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 623 | 1738 | return $i; | |||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||
| 626 | #---------------- | ||||||||||||||||||||||||||||||||||||||||||
| 627 | # Chapoton dexter | ||||||||||||||||||||||||||||||||||||||||||
| 628 | # Movable x is 0, x, (1 or end) | ||||||||||||||||||||||||||||||||||||||||||
| 629 | # /\/\ | ||||||||||||||||||||||||||||||||||||||||||
| 630 | # /\/ \/\ | ||||||||||||||||||||||||||||||||||||||||||
| 631 | # ****** | ||||||||||||||||||||||||||||||||||||||||||
| 632 | # ** | ||||||||||||||||||||||||||||||||||||||||||
| 633 | # NOT: ** followed by 0 | ||||||||||||||||||||||||||||||||||||||||||
| 634 | # | ||||||||||||||||||||||||||||||||||||||||||
| 635 | # from 000 1xx0 (1 or end) | ||||||||||||||||||||||||||||||||||||||||||
| 636 | # to 1xx0 000 | ||||||||||||||||||||||||||||||||||||||||||
| 637 | # | ||||||||||||||||||||||||||||||||||||||||||
| 638 | # forwards form as used here: | ||||||||||||||||||||||||||||||||||||||||||
| 639 | # from (0 or start) 1xx0 111 | ||||||||||||||||||||||||||||||||||||||||||
| 640 | # to 111 1xx0 | ||||||||||||||||||||||||||||||||||||||||||
| 641 | # | ||||||||||||||||||||||||||||||||||||||||||
| 642 | # Decomposition 1 A 0 1 B 0 1 C 0 ... = left child subtrees off the right arm. | ||||||||||||||||||||||||||||||||||||||||||
| 643 | # Block indecomposable 1 A 1 B 1 C ... 0 0 0, string ending k+1 many 0s. | ||||||||||||||||||||||||||||||||||||||||||
| 644 | # Level decomposition = A, B, C | ||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||
| 646 | 1 | ▶ | use constant _rel_type_name_dexter => 'Dexter'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 647 | 823 | ▶ | sub _rel_type_dexter { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rel_type_dexter: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||
| 648 | 823 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 649 | ### _rel_type_shift(): join('',@$aref) | ||||||||||||||||||||||||||||||||||||||||||
| 650 | 823 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 651 | 823 | foreach my $i (1 .. $#$aref-1) { | |||||||||||||||||||||||||||||||||||||||||
| 652 | 8676 | ▶ | if (!$aref->[$i] && $aref->[$i+1]) { # 01 of rotate | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $aref->[$i] and $$aref[$i + 1]
MC/DC100%2/2
not $aref->[$i] and $$aref[$i + 1]
not $aref->[$i]
$$aref[$i + 1]
Truth table100%3/3
not(A) and B
A= not $aref->[$i]B= $$aref[$i + 1]
| |||||||||||||||||||||||||||||||||||||||||||
| 653 | ### $i | ||||||||||||||||||||||||||||||||||||||||||
| 654 | 2169 | ▶ | for (my $e = $i+1; $aref->[$e]; $e++) { # one or more 1s after | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 655 | # $j = start of balanced | ||||||||||||||||||||||||||||||||||||||||||
| 656 | # $i = end of balanced | ||||||||||||||||||||||||||||||||||||||||||
| 657 | # $i+1 = first 1 after | ||||||||||||||||||||||||||||||||||||||||||
| 658 | # $e = end of 1s after, being position of last 1 | ||||||||||||||||||||||||||||||||||||||||||
| 659 | 3302 | my $d = 0; | |||||||||||||||||||||||||||||||||||||||||
| 660 | 3302 | foreach my $j (reverse 0 .. $i) { | |||||||||||||||||||||||||||||||||||||||||
| 661 | 11006 | ▶ | unless ($d += $pm_one[$aref->[$j]]) { # first return to zero | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 662 | 3302 | ▶ | if ($j == 0 || $aref->[$j-1]==0) { # only 0 or start preceding | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$j == 0 or $$aref[$j - 1] == 0
MC/DC100%2/2
$j == 0 or $$aref[$j - 1] == 0
$j == 0
$$aref[$j - 1] == 0
Truth table100%3/3
A or B
A= $j == 0B= $$aref[$j - 1] == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 663 | 2169 | push @ret, [ @{$aref}[0..$j-1], | |||||||||||||||||||||||||||||||||||||||||
| 664 | 2169 | @{$aref}[$i+1..$e], | |||||||||||||||||||||||||||||||||||||||||
| 665 | 2169 | @{$aref}[$j..$i], | |||||||||||||||||||||||||||||||||||||||||
| 666 | 2169 | @{$aref}[$e+1..$#$aref] ]; | |||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||
| 668 | 3302 | last; | |||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||
| 674 | 823 | return @ret; | |||||||||||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | #---------------- | ||||||||||||||||||||||||||||||||||||||||||
| 678 | # Split = Kreweras | ||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||
| 680 | # Refinement of partition is when one or more partition sets split into | ||||||||||||||||||||||||||||||||||||||||||
| 681 | # other sets. | ||||||||||||||||||||||||||||||||||||||||||
| 682 | # Coarsening is combining one or more sets. | ||||||||||||||||||||||||||||||||||||||||||
| 683 | # Order by refinement is Kreweras. | ||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||
| 685 | 1 | ▶ | use constant _rel_type_name_split => 'Split'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 686 | 2707 | ▶ | sub _rel_type_split { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rel_type_split: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||
| 687 | 2707 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 688 | ### _rel_type_split(): join('',@$aref) | ||||||||||||||||||||||||||||||||||||||||||
| 689 | 2707 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 690 | 2707 | foreach my $i (1 .. $#$aref-1) { | |||||||||||||||||||||||||||||||||||||||||
| 691 | 29438 | ▶ | if (!$aref->[$i] && $aref->[$i+1]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $aref->[$i] and $$aref[$i + 1]
MC/DC100%2/2
not $aref->[$i] and $$aref[$i + 1]
not $aref->[$i]
$$aref[$i + 1]
Truth table100%3/3
not(A) and B
A= not $aref->[$i]B= $$aref[$i + 1]
| |||||||||||||||||||||||||||||||||||||||||||
| 692 | ### $i | ||||||||||||||||||||||||||||||||||||||||||
| 693 | 7360 | my $e = $i+2; | |||||||||||||||||||||||||||||||||||||||||
| 694 | 7360 | ▶ | while ($aref->[$e]) { $e++; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 695 | 7360 | $e--; | |||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | # $j = start of balanced | ||||||||||||||||||||||||||||||||||||||||||
| 698 | # $i = end of balanced | ||||||||||||||||||||||||||||||||||||||||||
| 699 | # $i+1 = first 1 after | ||||||||||||||||||||||||||||||||||||||||||
| 700 | # $e = end of 1s after | ||||||||||||||||||||||||||||||||||||||||||
| 701 | 7360 | my $d = 0; | |||||||||||||||||||||||||||||||||||||||||
| 702 | 7360 | foreach my $j (reverse 0 .. $i) { | |||||||||||||||||||||||||||||||||||||||||
| 703 | 41859 | ▶ | unless ($d += $pm_one[$aref->[$j]]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 704 | 11266 | push @ret, [ @{$aref}[0..$j-1], | |||||||||||||||||||||||||||||||||||||||||
| 705 | 11266 | @{$aref}[$i+1..$e], | |||||||||||||||||||||||||||||||||||||||||
| 706 | 11266 | @{$aref}[$j..$i], | |||||||||||||||||||||||||||||||||||||||||
| 707 | 11266 | @{$aref}[$e+1..$#$aref] ]; | |||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||
| 709 | 41859 | ▶ | last if $d > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||
| 713 | 2707 | return @ret; | |||||||||||||||||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||
| 716 | #--------- | ||||||||||||||||||||||||||||||||||||||||||
| 717 | # Flip = Stanley | ||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||
| 719 | # Richard P. Stanley, "The Fibonacci Lattice", Fibonacci Quarterly, volume | ||||||||||||||||||||||||||||||||||||||||||
| 720 | # 13, number 3, October 1975, pages 215-232. | ||||||||||||||||||||||||||||||||||||||||||
| 721 | # https://fq.math.ca/13-3.html | ||||||||||||||||||||||||||||||||||||||||||
| 722 | # https://fq.math.ca/Scanned/13-3/stanley.pdf | ||||||||||||||||||||||||||||||||||||||||||
| 723 | # | ||||||||||||||||||||||||||||||||||||||||||
| 724 | # order ideal of lattice = subset of vertices, and all preceding all of them | ||||||||||||||||||||||||||||||||||||||||||
| 725 | # J(lattice) = lattice of order ideals, ordered by set inclusion | ||||||||||||||||||||||||||||||||||||||||||
| 726 | # T2 = infinite complete binary tree, W-ordered covers 1 smaller and 2 bigger | ||||||||||||||||||||||||||||||||||||||||||
| 727 | # order ideal of T2 = binary tree | ||||||||||||||||||||||||||||||||||||||||||
| 728 | # j[k] = num order ideals of T2 of cardinality k = Catalan(k) | ||||||||||||||||||||||||||||||||||||||||||
| 729 | # J(S(k-1)) = Stanley lattice | ||||||||||||||||||||||||||||||||||||||||||
| 730 | # S(P) = set of segments (or intervals) of P, ordered by inclusion | ||||||||||||||||||||||||||||||||||||||||||
| 731 | # . | ||||||||||||||||||||||||||||||||||||||||||
| 732 | # | ||||||||||||||||||||||||||||||||||||||||||
| 733 | # . . | ||||||||||||||||||||||||||||||||||||||||||
| 734 | # | ||||||||||||||||||||||||||||||||||||||||||
| 735 | # . * . 0 segs | ||||||||||||||||||||||||||||||||||||||||||
| 736 | # / \ | ||||||||||||||||||||||||||||||||||||||||||
| 737 | # . * * . 1 segs L or R | ||||||||||||||||||||||||||||||||||||||||||
| 738 | # / \ / \ | ||||||||||||||||||||||||||||||||||||||||||
| 739 | # . * * * . 2 segs LL L+R RR | ||||||||||||||||||||||||||||||||||||||||||
| 740 | # S(3) | ||||||||||||||||||||||||||||||||||||||||||
| 741 | # | ||||||||||||||||||||||||||||||||||||||||||
| 742 | # Order ideal subset of S(3) vertices - start outside, step to first of S(3) | ||||||||||||||||||||||||||||||||||||||||||
| 743 | # left arm, follow its vertices stepwise to right arm, exit there. | ||||||||||||||||||||||||||||||||||||||||||
| 744 | # Is 4 steps across and 4 steps down per Dyck crossing of 4x4 half grid. | ||||||||||||||||||||||||||||||||||||||||||
| 745 | # | ||||||||||||||||||||||||||||||||||||||||||
| 746 | # J(S(3)) = Stanley N=4 | ||||||||||||||||||||||||||||||||||||||||||
| 747 | # 4-elem sets of S(3) | ||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||||||||||
| 750 | 1 | ▶ | use constant _rel_type_name_flip => 'Flip'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 751 | 2734 | ▶ | sub _rel_type_flip { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rel_type_flip: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 752 | 2734 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 753 | 2734 | my @ret; | |||||||||||||||||||||||||||||||||||||||||
| 754 | 2734 | foreach my $i (1 .. $#$aref-1) { | |||||||||||||||||||||||||||||||||||||||||
| 755 | 29600 | ▶ | if (!$aref->[$i] && $aref->[$i+1]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $aref->[$i] and $$aref[$i + 1]
MC/DC100%2/2
not $aref->[$i] and $$aref[$i + 1]
not $aref->[$i]
$$aref[$i + 1]
Truth table100%3/3
not(A) and B
A= not $aref->[$i]B= $$aref[$i + 1]
| |||||||||||||||||||||||||||||||||||||||||||
| 756 | 7400 | my @new_aref = @$aref; | |||||||||||||||||||||||||||||||||||||||||
| 757 | 7400 | $new_aref[$i] = 1; | |||||||||||||||||||||||||||||||||||||||||
| 758 | 7400 | $new_aref[$i+1] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 759 | 7400 | push @ret, \@new_aref; | |||||||||||||||||||||||||||||||||||||||||
| 760 | } | ||||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||
| 762 | 2734 | return @ret; | |||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||
| 765 | #--------- | ||||||||||||||||||||||||||||||||||||||||||
| 766 | # Filling = all flips | ||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||
| 768 | 1 | ▶ | use constant _rel_type_name_filling => 'Filling'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 769 | 1490 | ▶ | sub _rel_type_filling { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_rel_type_filling: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 770 | 1490 | my ($aref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 771 | 1490 | my @new_aref = @$aref; | |||||||||||||||||||||||||||||||||||||||||
| 772 | 1490 | my $seen; | |||||||||||||||||||||||||||||||||||||||||
| 773 | 1490 | foreach my $i (1 .. $#$aref-1) { | |||||||||||||||||||||||||||||||||||||||||
| 774 | 15932 | ▶ | if (!$aref->[$i] && $aref->[$i+1]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $aref->[$i] and $$aref[$i + 1]
MC/DC100%2/2
not $aref->[$i] and $$aref[$i + 1]
not $aref->[$i]
$$aref[$i + 1]
Truth table100%3/3
not(A) and B
A= not $aref->[$i]B= $$aref[$i + 1]
| |||||||||||||||||||||||||||||||||||||||||||
| 775 | 3983 | $new_aref[$i] = 1; | |||||||||||||||||||||||||||||||||||||||||
| 776 | 3983 | $new_aref[$i+1] = 0; | |||||||||||||||||||||||||||||||||||||||||
| 777 | 3983 | $seen = 1; | |||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||
| 779 | } | ||||||||||||||||||||||||||||||||||||||||||
| 780 | 1490 | ▶ | return ($seen ? \@new_aref : ()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||
| 783 | #------------------ | ||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||
| 785 | 244 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=16 SCAR=27.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 786 | 244 | my ($self, %params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 787 | ### Catalans init ... | ||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||
| 789 | 244 | ▶ | my $N = delete($params{'N'}) || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $params{'N'} || 0
MC/DC100%1/1
delete $params{'N'} || 0
delete $params{'N'}
Truth table100%2/2
A
A= delete $params{'N'}
| |||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||
| 791 | 244 | ▶ | my $rel_type = delete($params{'rel_type'}) || 'rotate'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $params{'rel_type'} || 'rotate'
MC/DC100%1/1
delete $params{'rel_type'} || 'rotate'
delete $params{'rel_type'}
Truth table100%2/2
A
A= delete $params{'rel_type'}
| |||||||||||||||||||||||||||||||||||||||||||
| 792 | 244 | ▶ | my $rel_type_func = $self->can("_rel_type_$rel_type") | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->can("_rel_type_$rel_type") || croak('Unrecognised rel_type: ', $rel_type)
MC/DC0%0/1
$self->can("_rel_type_$rel_type") || croak('Unrecognised rel_type: ', $rel_type)
$self->can("_rel_type_$rel_type")
Truth table50%1/2
A
A= $self->can("_rel_type_$rel_type")
| |||||||||||||||||||||||||||||||||||||||||||
| 793 | || croak "Unrecognised rel_type: ",$rel_type; | ||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||
| 795 | 244 | ▶ | my $rel_direction = delete($params{'rel_direction'}) || 'up'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $params{'rel_direction'} || 'up'
MC/DC100%1/1
delete $params{'rel_direction'} || 'up'
delete $params{'rel_direction'}
Truth table100%2/2
A
A= delete $params{'rel_direction'}
| |||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||
| 797 | 244 | ▶ | my $vertex_name_type = delete($params{'vertex_name_type'}) || 'balanced'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $params{'vertex_name_type'} || 'balanced'
MC/DC100%1/1
delete $params{'vertex_name_type'} || 'balanced'
delete $params{'vertex_name_type'}
Truth table100%2/2
A
A= delete $params{'vertex_name_type'}
| |||||||||||||||||||||||||||||||||||||||||||
| 798 | 244 | ▶ | my $order = delete($params{'order'}) || 'pre'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $params{'order'} || 'pre'
MC/DC0%0/1
delete $params{'order'} || 'pre'
delete $params{'order'}
Truth table50%1/2
A
A= delete $params{'order'}
| |||||||||||||||||||||||||||||||||||||||||||
| 799 | 244 | ▶ | my $vertex_name_func = $self->can("_vertex_name_type_$vertex_name_type") | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->can("_vertex_name_type_$vertex_name_type") || croak('Unrecognised vertex_name_type: ', $vertex_name_type)
MC/DC0%0/1
$self->can("_vertex_name_type_$vertex_name_type") || croak('Unrecognised vertex_name_type: ', $vertex_name_type)
$self->can("_vertex_name_type_$vertex_name_type")
Truth table50%1/2
A
A= $self->can("_vertex_name_type_$vertex_name_type")
| |||||||||||||||||||||||||||||||||||||||||||
| 800 | || croak "Unrecognised vertex_name_type: ",$vertex_name_type; | ||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||
| 802 | 244 | my $comma = delete($params{'comma'}); | |||||||||||||||||||||||||||||||||||||||||
| 803 | 244 | ▶ | unless (defined $comma) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 804 | 238 | ▶ | $comma = ($vertex_name_type eq 'balanced' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$vertex_name_type eq "balanced" or $vertex_name_type eq "balanced_postorder"
MC/DC100%2/2
$vertex_name_type eq "balanced" or $vertex_name_type eq "balanced_postorder"
$vertex_name_type eq "balanced"
$vertex_name_type eq "balanced_postorder"
Truth table100%3/3
A or B
A= $vertex_name_type eq "balanced"B= $vertex_name_type eq "balanced_postorder"
| |||||||||||||||||||||||||||||||||||||||||||
| 805 | || $vertex_name_type eq 'balanced_postorder' | ||||||||||||||||||||||||||||||||||||||||||
| 806 | ? '' : ','); | ||||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||
| 809 | 244 | my $graph = _make_graph(\%params); | |||||||||||||||||||||||||||||||||||||||||
| 810 | 244 | $graph->set_graph_attribute | |||||||||||||||||||||||||||||||||||||||||
| 811 | (name => "Catalans N=$N, " . $self->can("_rel_type_name_$rel_type")->()); | ||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||
| 813 | 244 | ▶ | unless ($graph->is_directed) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 814 | 21 | $rel_direction = 'up'; | |||||||||||||||||||||||||||||||||||||||||
| 815 | } | ||||||||||||||||||||||||||||||||||||||||||
| 816 | 244 | my $up = ($rel_direction ne 'down'); | |||||||||||||||||||||||||||||||||||||||||
| 817 | 244 | my $down = ($rel_direction ne 'up'); | |||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||
| 819 | 244 | my @array = (1,0) x $N; | |||||||||||||||||||||||||||||||||||||||||
| 820 | 244 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 821 | 14160 | my $from = join($comma,$vertex_name_func->(\@array)); | |||||||||||||||||||||||||||||||||||||||||
| 822 | 14160 | $graph->add_vertex($from); | |||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||
| 824 | ### array: join('',@array) | ||||||||||||||||||||||||||||||||||||||||||
| 825 | ### $from | ||||||||||||||||||||||||||||||||||||||||||
| 826 | 14160 | foreach my $to_aref ($rel_type_func->(\@array)) { | |||||||||||||||||||||||||||||||||||||||||
| 827 | 33022 | my $to = join($comma,$vertex_name_func->($to_aref)); | |||||||||||||||||||||||||||||||||||||||||
| 828 | ### to array: join('',@$to_aref) | ||||||||||||||||||||||||||||||||||||||||||
| 829 | ### $to | ||||||||||||||||||||||||||||||||||||||||||
| 830 | 33022 | ▶ | if ($up) { $graph->add_edge($from,$to); } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 831 | 33022 | ▶ | if ($down) { $graph->add_edge($to,$from); } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||||||||||||||||
| 833 | } while (_balanced_next(\@array)); | ||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||
| 835 | ### total vertices: scalar $graph->vertices | ||||||||||||||||||||||||||||||||||||||||||
| 836 | ### total edges : scalar $graph->edges | ||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||
| 838 | 244 | return $graph; | |||||||||||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||
| 841 | 1 | Graph::Maker->add_factory_type('Catalans' => __PACKAGE__); | |||||||||||||||||||||||||||||||||||||||||
| 842 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||
| 844 | __END__ | ||||||||||||||||||||||||||||||||||||||||||