| 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])
$old->has($_->[0]) and not $old->has($_->[1])
$old->has($_->[1]) and not $old->has($_->[0])
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])
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | next if $graph->has_edge( $new, $neighbour ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | $graph->add_edge( $new, $neighbour ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | next unless $graph->has_edge_attributes( @$edge ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||