MoreUtils/Replace.pm

filter: Statementstmt 47.8% 11 / 23 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 75.0% 3 / 4 Podpod 0.0% 0 / 1 totaltotal 29.7% 14 / 47 CC 8 SCAR 39.6
CC
8
Cov
29%
replace
72.0
BEGIN
1.0
BEGIN
1.0
CRAP 52.6
↑ Summary MoreUtils/Smooth.pm »
1 package Graph::MoreUtils::Replace;
2  
3 # ABSTRACT: Replace one on more vertices with a given one.
4 8 our $VERSION = '0.3.0'; # VERSION
5  
6 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 8 ▶use Set::Object qw( set );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub replace
12 0 ▶{
Subroutine replace: not called CC=8 SCAR=42.8
Pod undocumented
13 0 my( $graph, $new, @old ) = @_;
14  
15 0 $graph->add_vertex( $new );
16  
17 0 my $old = set( @old );
18 0 ▶ for my $edge (grep { ($old->has( $_->[0] ) && !$old->has( $_->[1] )) ||
Condition0%0/9
$old->has($_->[0]) && !$old->has($_->[1]) || $old->has($_->[1]) && !$old->has($_->[0])
l!l&&r!l&&!r
000
$old->has($_->[0]) and not $old->has($_->[1])
!ll&&!rl&&r
000
$old->has($_->[1]) and not $old->has($_->[0])
!ll&&!rl&&r
000
MC/DC0%0/4
$old->has($_->[0]) && !$old->has($_->[1]) || $old->has($_->[1]) && !$old->has($_->[0])
$old->has($_->[0]) not $old->has($_->[1]) $old->has($_->[1]) not $old->has($_->[0])
Truth table0%0/7
A and not(B) || C and not(D)
A= $old->has($_->[0])B= not $old->has($_->[1])C= $old->has($_->[1])D= not $old->has($_->[0])
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
19 ($old->has( $_->[1] ) && !$old->has( $_->[0] )) }
20 $graph->edges) {
21 0 ▶ my( $vertex, $neighbour ) = $old->has( $edge->[0] ) ? @$edge : reverse @$edge;
Branch: 1 branch
BranchTrueFalseTotal
$old->has($edge->[0]) ? : 0 0 0
22 0 ▶ next if $graph->has_edge( $new, $neighbour );
Branch: 1 branch
BranchTrueFalseTotal
if $graph->has_edge($new, $neighbour) 0 0 0
23 0 $graph->add_edge( $new, $neighbour );
24 0 ▶ next unless $graph->has_edge_attributes( @$edge );
Branch: 1 branch
BranchTrueFalseTotal
unless $graph->has_edge_attributes(@$edge) 0 0 0
25 0 $graph->set_edge_attributes( $new, $neighbour, $graph->get_edge_attributes( @$edge ) );
26 }
27 0 $graph->delete_vertices( @old );
28  
29 0 return $graph;
30 }
31  
32 8 1;
↑ Summary MoreUtils/Smooth.pm »