blib/lib/Graph/SomeUtils.pm

filter: Statementstmt 62.5% 35 / 56 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 9 / 15 Podpod 100% 10 / 10 totaltotal 67.4% 56 / 83 CC 8 SCAR 13.3
CC
8
Cov
64%
graph_isolate_vertex
12.0
graph_vertices_between
6.0
graph_delete_vertex_fast
4.0
CRAP 3.8
↑ Summary
1 package Graph::SomeUtils;
2  
3 4 ▶use 5.012000;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Graph;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 our $VERSION = '0.20';
10  
11 4 our %EXPORT_TAGS = ( 'all' => [ qw(
12 graph_delete_vertices_fast
13 graph_delete_vertex_fast
14 graph_all_successors_and_self
15 graph_all_predecessors_and_self
16 graph_vertices_between
17 graph_get_vertex_label
18 graph_set_vertex_label
19 graph_isolate_vertex
20 graph_delete_vertices_except
21 graph_truncate_to_vertices_between
22 ) ] );
23  
24 4 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
25  
26 4 our @EXPORT = qw(
27 );
28  
29 1 ▶sub graph_get_vertex_label {
Subroutine graph_get_vertex_label: called CC=1 SCAR=0.0
Pod documented
30 1 my ($g, $v) = @_;
31 1 return $g->get_vertex_attribute($v, 'label');
32 }
33  
34 1 ▶sub graph_set_vertex_label {
Subroutine graph_set_vertex_label: called CC=1 SCAR=0.0
Pod documented
35 1 my ($g, $v, $label) = @_;
36 1 $g->set_vertex_attribute($v, 'label', $label);
37 }
38  
39 787 ▶sub graph_delete_vertex_fast {
Subroutine graph_delete_vertex_fast: called CC=4 SCAR=13.9
Pod documented
40 787 my $g = shift;
41 787 $g->expect_non_unionfind;
42 787 my $V = $g->[ Graph::_V ];
43 787 ▶ return $g unless $V->has_path( @_ );
Branch: 1 branch
BranchTrueFalseTotal
unless $V->has_path(@_) 215 572 787
44 572 $g->delete_edge($_[0], $_) for $g->successors($_[0]);
45 572 $g->delete_edge($_, $_[0]) for $g->predecessors($_[0]);
46 572 $V->del_path( @_ );
47 572 $g->[ Graph::_G ]++;
48 572 return $g;
49 }
50  
51 40 ▶sub graph_delete_vertices_fast {
Subroutine graph_delete_vertices_fast: called CC=2 SCAR=6.9
Pod documented
52 40 my $g = shift;
53 40 graph_delete_vertex_fast($g, $_) for @_;
54 }
55  
56 0 ▶sub graph_vertices_between {
Subroutine graph_vertices_between: not called CC=2 SCAR=17.9
Pod documented
57 0 my ($g, $src, $dst) = @_;
58 0 my %from_src;
59
60 0 $from_src{$_}++ for graph_all_successors_and_self($g, $src);
61
62 return grep {
63 0 $from_src{$_}
64 } graph_all_predecessors_and_self($g, $dst);
65 }
66  
67 0 ▶sub graph_all_successors_and_self {
Subroutine graph_all_successors_and_self: not called CC=1 SCAR=6.9
Pod documented
68 0 my ($g, $v) = @_;
69 0 return ((grep { $_ ne $v } $g->all_successors($v)), $v);
70 }
71  
72 0 ▶sub graph_all_predecessors_and_self {
Subroutine graph_all_predecessors_and_self: not called CC=1 SCAR=6.9
Pod documented
73 0 my ($g, $v) = @_;
74 0 return ((grep { $_ ne $v } $g->all_predecessors($v)), $v);
75 }
76  
77 0 ▶sub graph_isolate_vertex {
Subroutine graph_isolate_vertex: not called CC=3 SCAR=24.8
Pod documented
78 0 my ($g, $vertex) = @_;
79 0 $g->delete_edge($vertex, $_) for $g->successors($vertex);
80 0 $g->delete_edge($_, $vertex) for $g->predecessors($vertex);
81 }
82  
83 0 ▶sub graph_delete_vertices_except {
Subroutine graph_delete_vertices_except: not called CC=1 SCAR=6.9
Pod documented
84 0 my ($g, @vertices) = @_;
85 0 my %keep = map { $_ => 1 } @vertices;
86  
87 graph_delete_vertices_fast($g,
88 0 grep { not $keep{$_} } $g->vertices);
89 }
90  
91 0 ▶sub graph_truncate_to_vertices_between {
Subroutine graph_truncate_to_vertices_between: not called CC=1 SCAR=6.9
Pod documented
92 0 my ($g, $start, $final) = @_;
93 0 graph_delete_vertices_except($g,
94 graph_vertices_between($g, $start, $final));
95 }
96  
97 4 1;
98  
99 __END__
↑ Summary