line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Graph::SomeUtils;
|
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
98664
|
use 5.012000;
|
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
97
|
|
4
|
3
|
|
|
3
|
|
16
|
use strict;
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
96
|
|
5
|
3
|
|
|
3
|
|
16
|
use warnings;
|
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
224
|
|
6
|
3
|
|
|
3
|
|
15
|
use base qw(Exporter);
|
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
381
|
|
7
|
3
|
|
|
3
|
|
3551
|
use Graph;
|
|
3
|
|
|
|
|
618829
|
|
|
3
|
|
|
|
|
1647
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.02';
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our @EXPORT = qw(
|
24
|
|
|
|
|
|
|
);
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub graph_get_vertex_label {
|
27
|
1
|
|
|
1
|
1
|
24597
|
my ($g, $v) = @_;
|
28
|
1
|
|
|
|
|
8
|
return $g->get_vertex_attribute($v, 'label');
|
29
|
|
|
|
|
|
|
}
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub graph_set_vertex_label {
|
32
|
1
|
|
|
1
|
1
|
3042512
|
my ($g, $v, $label) = @_;
|
33
|
1
|
|
|
|
|
7
|
$g->set_vertex_attribute($v, 'label', $label);
|
34
|
|
|
|
|
|
|
}
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub graph_delete_vertex_fast {
|
37
|
732
|
|
|
732
|
1
|
3312
|
my $g = shift;
|
38
|
732
|
|
|
|
|
7831
|
$g->expect_non_unionfind;
|
39
|
732
|
|
|
|
|
4618
|
my $V = $g->[ Graph::_V ];
|
40
|
732
|
100
|
|
|
|
2174
|
return $g unless $V->has_path( @_ );
|
41
|
541
|
|
|
|
|
6887
|
$g->delete_edge($_[0], $_) for $g->successors($_[0]);
|
42
|
541
|
|
|
|
|
650614
|
$g->delete_edge($_, $_[0]) for $g->predecessors($_[0]);
|
43
|
541
|
|
|
|
|
197974
|
$V->del_path( @_ );
|
44
|
541
|
|
|
|
|
13339
|
$g->[ Graph::_G ]++;
|
45
|
541
|
|
|
|
|
1650
|
return $g;
|
46
|
|
|
|
|
|
|
}
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub graph_delete_vertices_fast {
|
49
|
40
|
|
|
40
|
1
|
5787704
|
my $g = shift;
|
50
|
40
|
|
|
|
|
1545
|
graph_delete_vertex_fast($g, $_) for @_;
|
51
|
|
|
|
|
|
|
}
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub graph_vertices_between {
|
54
|
0
|
|
|
0
|
1
|
|
my ($g, $src, $dst) = @_;
|
55
|
0
|
|
|
|
|
|
my %from_src;
|
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$from_src{$_}++ for graph_all_successors_and_self($g, $src);
|
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
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
|
|
|
0
|
1
|
|
my ($g, $v) = @_;
|
66
|
0
|
|
|
|
|
|
return ((grep { $_ ne $v } $g->all_successors($v)), $v);
|
|
0
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
}
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub graph_all_predecessors_and_self {
|
70
|
0
|
|
|
0
|
1
|
|
my ($g, $v) = @_;
|
71
|
0
|
|
|
|
|
|
return ((grep { $_ ne $v } $g->all_predecessors($v)), $v);
|
|
0
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
}
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1;
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__
|