blib/lib/Graph/SomeUtils.pm

filter: Statementstmt 76.0% 35 / 46 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 9 / 12 Podpod 100% 7 / 7 totaltotal 79.1% 53 / 67 SCAR 18.6
CC
6
Cov
77%
graph_vertices_between
6.0
graph_delete_vertex_fast
4.0
graph_delete_vertices_fast
2.0
CRAP 6.4
↑ 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.02';
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 ) ] );
20
21 4 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
22
23 4 our @EXPORT = qw(
24 );
25
26 sub graph_get_vertex_label {
27 1 ▶ my ($g, $v) = @_;
Subroutine graph_get_vertex_label: called CC=1 SCAR=0.0
Pod documented
28 1 return $g->get_vertex_attribute($v, 'label');
29 }
30
31 sub graph_set_vertex_label {
32 1 ▶ my ($g, $v, $label) = @_;
Subroutine graph_set_vertex_label: called CC=1 SCAR=0.0
Pod documented
33 1 $g->set_vertex_attribute($v, 'label', $label);
34 }
35
36 sub graph_delete_vertex_fast {
37 727 ▶ my $g = shift;
Subroutine graph_delete_vertex_fast: called CC=4 SCAR=13.9
Pod documented
38 727 $g->expect_non_unionfind;
39 727 my $V = $g->[ Graph::_V ];
40 727 ▶ return $g unless $V->has_path( @_ );
Branch: 1 branch
BranchTrueFalseTotal
unless $V->has_path(@_) 202 525 727
41 525 $g->delete_edge($_[0], $_) for $g->successors($_[0]);
42 525 $g->delete_edge($_, $_[0]) for $g->predecessors($_[0]);
43 525 $V->del_path( @_ );
44 525 $g->[ Graph::_G ]++;
45 525 return $g;
46 }
47
48 sub graph_delete_vertices_fast {
49 40 ▶ my $g = shift;
Subroutine graph_delete_vertices_fast: called CC=2 SCAR=6.9
Pod documented
50 40 graph_delete_vertex_fast($g, $_) for @_;
51 }
52
53 sub graph_vertices_between {
54 0 ▶ my ($g, $src, $dst) = @_;
Subroutine graph_vertices_between: not called CC=2 SCAR=17.9
Pod documented
55 0 my %from_src;
56
57 0 $from_src{$_}++ for graph_all_successors_and_self($g, $src);
58
59 return grep {
60 0 $from_src{$_}
61 } graph_all_predecessors_and_self($g, $dst);
62 }
63
64 sub graph_all_successors_and_self {
65 0 ▶ my ($g, $v) = @_;
Subroutine graph_all_successors_and_self: not called CC=1 SCAR=6.9
Pod documented
66 0 return ((grep { $_ ne $v } $g->all_successors($v)), $v);
67 }
68
69 sub graph_all_predecessors_and_self {
70 0 ▶ my ($g, $v) = @_;
Subroutine graph_all_predecessors_and_self: not called CC=1 SCAR=6.9
Pod documented
71 0 return ((grep { $_ ne $v } $g->all_predecessors($v)), $v);
72 }
73
74 4 1;
75
76 __END__
↑ Summary