← 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:28 2015

Filename/Users/ap13/perl5/lib/perl5/Graph/AdjacencyMatrix.pm
StatementsExecuted 11 statements in 911µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111965µs987µsGraph::AdjacencyMatrix::::BEGIN@5Graph::AdjacencyMatrix::BEGIN@5
111394µs443µsGraph::AdjacencyMatrix::::BEGIN@6Graph::AdjacencyMatrix::BEGIN@6
11118µs128µsGraph::AdjacencyMatrix::::BEGIN@8Graph::AdjacencyMatrix::BEGIN@8
11113µs333µsGraph::AdjacencyMatrix::::BEGIN@10Graph::AdjacencyMatrix::BEGIN@10
11112µs23µsGraph::AdjacencyMatrix::::BEGIN@3Graph::AdjacencyMatrix::BEGIN@3
0000s0sGraph::AdjacencyMatrix::::adjacency_matrixGraph::AdjacencyMatrix::adjacency_matrix
0000s0sGraph::AdjacencyMatrix::::distanceGraph::AdjacencyMatrix::distance
0000s0sGraph::AdjacencyMatrix::::distance_matrixGraph::AdjacencyMatrix::distance_matrix
0000s0sGraph::AdjacencyMatrix::::is_adjacentGraph::AdjacencyMatrix::is_adjacent
0000s0sGraph::AdjacencyMatrix::::newGraph::AdjacencyMatrix::new
0000s0sGraph::AdjacencyMatrix::::verticesGraph::AdjacencyMatrix::vertices
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Graph::AdjacencyMatrix;
2
3227µs235µs
# spent 23µs (12+12) within Graph::AdjacencyMatrix::BEGIN@3 which was called: # once (12µs+12µs) by Graph::TransitiveClosure::Matrix::BEGIN@5 at line 3
use strict;
# spent 23µs making 1 call to Graph::AdjacencyMatrix::BEGIN@3 # spent 12µs making 1 call to strict::import
4
52126µs1987µs
# spent 987µs (965+22) within Graph::AdjacencyMatrix::BEGIN@5 which was called: # once (965µs+22µs) by Graph::TransitiveClosure::Matrix::BEGIN@5 at line 5
use Graph::BitMatrix;
# spent 987µs making 1 call to Graph::AdjacencyMatrix::BEGIN@5
62176µs1443µs
# spent 443µs (394+48) within Graph::AdjacencyMatrix::BEGIN@6 which was called: # once (394µs+48µs) by Graph::TransitiveClosure::Matrix::BEGIN@5 at line 6
use Graph::Matrix;
# spent 443µs making 1 call to Graph::AdjacencyMatrix::BEGIN@6
7
8250µs2238µs
# spent 128µs (18+110) within Graph::AdjacencyMatrix::BEGIN@8 which was called: # once (18µs+110µs) by Graph::TransitiveClosure::Matrix::BEGIN@5 at line 8
use base 'Graph::BitMatrix';
# spent 128µs making 1 call to Graph::AdjacencyMatrix::BEGIN@8 # spent 110µs making 1 call to base::import
9
102526µs2653µs
# spent 333µs (13+320) within Graph::AdjacencyMatrix::BEGIN@10 which was called: # once (13µs+320µs) by Graph::TransitiveClosure::Matrix::BEGIN@5 at line 10
use Graph::AdjacencyMap qw(:flags :fields);
# spent 333µs making 1 call to Graph::AdjacencyMatrix::BEGIN@10 # spent 320µs making 1 call to Exporter::import
11
12sub _V () { 2 } # Graph::_V
13sub _E () { 3 } # Graph::_E
14
15sub new {
16 my ($class, $g, %opt) = @_;
17 my $n;
18 my @V = $g->vertices;
19 my $want_distance;
20 if (exists $opt{distance_matrix}) {
21 $want_distance = $opt{distance_matrix};
22 delete $opt{distance_matrix};
23 }
24 my $d = Graph::_defattr();
25 if (exists $opt{attribute_name}) {
26 $d = $opt{attribute_name};
27 $want_distance++;
28 }
29 delete $opt{attribute_name};
30 my $want_transitive = 0;
31 if (exists $opt{is_transitive}) {
32 $want_transitive = $opt{is_transitive};
33 delete $opt{is_transitive};
34 }
35 Graph::_opt_unknown(\%opt);
36 if ($want_distance) {
37 $n = Graph::Matrix->new($g);
38 for my $v (@V) { $n->set($v, $v, 0) }
39 }
40 my $m = Graph::BitMatrix->new($g, connect_edges => $want_distance);
41 if ($want_distance) {
42 # for my $u (@V) {
43 # for my $v (@V) {
44 # if ($g->has_edge($u, $v)) {
45 # $n->set($u, $v,
46 # $g->get_edge_attribute($u, $v, $d));
47 # }
48 # }
49 # }
50 my $Vi = $g->[_V]->[_i];
51 my $Ei = $g->[_E]->[_i];
52 my %V; @V{ @V } = 0 .. $#V;
53 my $n0 = $n->[0];
54 my $n1 = $n->[1];
55 if ($g->is_undirected) {
56 for my $e (keys %{ $Ei }) {
57 my ($i0, $j0) = @{ $Ei->{ $e } };
58 my $i1 = $V{ $Vi->{ $i0 } };
59 my $j1 = $V{ $Vi->{ $j0 } };
60 my $u = $V[ $i1 ];
61 my $v = $V[ $j1 ];
62 $n0->[ $i1 ]->[ $j1 ] =
63 $g->get_edge_attribute($u, $v, $d);
64 $n0->[ $j1 ]->[ $i1 ] =
65 $g->get_edge_attribute($v, $u, $d);
66 }
67 } else {
68 for my $e (keys %{ $Ei }) {
69 my ($i0, $j0) = @{ $Ei->{ $e } };
70 my $i1 = $V{ $Vi->{ $i0 } };
71 my $j1 = $V{ $Vi->{ $j0 } };
72 my $u = $V[ $i1 ];
73 my $v = $V[ $j1 ];
74 $n0->[ $i1 ]->[ $j1 ] =
75 $g->get_edge_attribute($u, $v, $d);
76 }
77 }
78 }
79 bless [ $m, $n, [ @V ] ], $class;
80}
81
82sub adjacency_matrix {
83 my $am = shift;
84 $am->[0];
85}
86
87sub distance_matrix {
88 my $am = shift;
89 $am->[1];
90}
91
92sub vertices {
93 my $am = shift;
94 @{ $am->[2] };
95}
96
97sub is_adjacent {
98 my ($m, $u, $v) = @_;
99 $m->[0]->get($u, $v) ? 1 : 0;
100}
101
102sub distance {
103 my ($m, $u, $v) = @_;
104 defined $m->[1] ? $m->[1]->get($u, $v) : undef;
105}
106
10716µs1;
108__END__