← Index
NYTProf Performance Profile   « block view • line view • sub view »
For bin/pan_genome_post_analysis
  Run on Fri Mar 27 11:43:32 2015
Reported on Fri Mar 27 11:45:51 2015

Filename/Users/ap13/perl5/lib/perl5/Graph/TransitiveClosure.pm
StatementsExecuted 7 statements in 504µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1111.50ms4.19msGraph::TransitiveClosure::::BEGIN@10Graph::TransitiveClosure::BEGIN@10
11112µs25µsGraph::TransitiveClosure::::BEGIN@3Graph::TransitiveClosure::BEGIN@3
1119µs68µsGraph::TransitiveClosure::::BEGIN@9Graph::TransitiveClosure::BEGIN@9
0000s0sGraph::TransitiveClosure::::_GGraph::TransitiveClosure::_G
0000s0sGraph::TransitiveClosure::::is_transitiveGraph::TransitiveClosure::is_transitive
0000s0sGraph::TransitiveClosure::::newGraph::TransitiveClosure::new
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Graph::TransitiveClosure;
2
3226µs238µs
# spent 25µs (12+13) within Graph::TransitiveClosure::BEGIN@3 which was called: # once (12µs+13µs) by Graph::BEGIN@32 at line 3
use strict;
# spent 25µs making 1 call to Graph::TransitiveClosure::BEGIN@3 # spent 13µs making 1 call to strict::import
4
5# COMMENT THESE OUT FOR TESTING AND PRODUCTION.
6# $SIG{__DIE__ } = sub { use Carp; confess };
7# $SIG{__WARN__} = sub { use Carp; confess };
8
9230µs2127µs
# spent 68µs (9+59) within Graph::TransitiveClosure::BEGIN@9 which was called: # once (9µs+59µs) by Graph::BEGIN@32 at line 9
use base 'Graph';
# spent 68µs making 1 call to Graph::TransitiveClosure::BEGIN@9 # spent 59µs making 1 call to base::import
102444µs14.19ms
# spent 4.19ms (1.50+2.69) within Graph::TransitiveClosure::BEGIN@10 which was called: # once (1.50ms+2.69ms) by Graph::BEGIN@32 at line 10
use Graph::TransitiveClosure::Matrix;
# spent 4.19ms making 1 call to Graph::TransitiveClosure::BEGIN@10
11
12sub _G () { Graph::_G() }
13
14sub new {
15 my ($class, $g, %opt) = @_;
16 $g->expect_non_multiedged;
17 %opt = (path_vertices => 1) unless %opt;
18 my $attr = Graph::_defattr();
19 if (exists $opt{ attribute_name }) {
20 $attr = $opt{ attribute_name };
21 # No delete $opt{ attribute_name } since we need to pass it on.
22 }
23 $opt{ reflexive } = 1 unless exists $opt{ reflexive };
24 my $tcm = $g->new( $opt{ reflexive } ?
25 ( vertices => [ $g->vertices ] ) : ( ) );
26 my $tcg = $g->get_graph_attribute('_tcg');
27 if (defined $tcg && $tcg->[ 0 ] == $g->[ _G ]) {
28 $tcg = $tcg->[ 1 ];
29 } else {
30 $tcg = Graph::TransitiveClosure::Matrix->new($g, %opt);
31 $g->set_graph_attribute('_tcg', [ $g->[ _G ], $tcg ]);
32 }
33 my $tcg00 = $tcg->[0]->[0];
34 my $tcg11 = $tcg->[1]->[1];
35 for my $u ($tcg->vertices) {
36 my $tcg00i = $tcg00->[ $tcg11->{ $u } ];
37 for my $v ($tcg->vertices) {
38 next if $u eq $v && ! $opt{ reflexive };
39 my $j = $tcg11->{ $v };
40 if (
41 # $tcg->is_transitive($u, $v)
42 # $tcg->[0]->get($u, $v)
43 vec($tcg00i, $j, 1)
44 ) {
45 my $val = $g->_get_edge_attribute($u, $v, $attr);
46 $tcm->_set_edge_attribute($u, $v, $attr,
47 defined $val ? $val :
48 $u eq $v ?
49 0 : 1);
50 }
51 }
52 }
53 $tcm->set_graph_attribute('_tcm', $tcg);
54 bless $tcm, $class;
55}
56
57sub is_transitive {
58 my $g = shift;
59 Graph::TransitiveClosure::Matrix::is_transitive($g);
60}
61
6214µs1;
63__END__