line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package String::Eertree::ToDot; |
2
|
1
|
|
|
1
|
|
202363
|
use Moo; |
|
1
|
|
|
|
|
10335
|
|
|
1
|
|
|
|
|
5
|
|
3
|
|
|
|
|
|
|
extends 'String::Eertree'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub to_dot { |
6
|
1
|
|
|
1
|
0
|
10
|
my ($self) = @_; |
7
|
1
|
|
|
|
|
4
|
my @lines = ('digraph { rankdir = BT;'); |
8
|
1
|
|
|
|
|
3
|
for my $i (0 .. $self->Last) { |
9
|
9
|
|
|
|
|
19
|
my $node = $self->node($i); |
10
|
9
|
|
100
|
|
|
36
|
push @lines, qq($i [shape=record, label="$i|) |
11
|
|
|
|
|
|
|
. ($node->string($self) || $i - 1) . '"]'; |
12
|
9
|
|
|
|
|
25
|
push @lines, $i . '->' . $node->link . '[color=blue]'; |
13
|
|
|
|
|
|
|
} |
14
|
1
|
|
|
|
|
4
|
for my $i (0 .. $self->Last) { |
15
|
9
|
|
|
|
|
48
|
my $node = $self->node($i); |
16
|
9
|
|
|
|
|
11
|
for my $ch (sort keys %{ $node->edge }) { |
|
9
|
|
|
|
|
116
|
|
17
|
7
|
|
|
|
|
145
|
push @lines, $i . '->' . $node->edge->{$ch} |
18
|
|
|
|
|
|
|
. "[label=$ch, constraint=false]"; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
} |
21
|
1
|
|
|
|
|
2
|
push @lines, '}'; |
22
|
|
|
|
|
|
|
return @lines |
23
|
1
|
|
|
|
|
48
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
String::Eertree::ToDot - Draw the Eertree graph using graphviz |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 VERSION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Version 0.01 |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
This class behaves exactly the same as C, but it adds |
40
|
|
|
|
|
|
|
a new method C. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $tree = 'String::Eertree::ToDot(string => 'eertree'); |
43
|
|
|
|
|
|
|
print $tree->to_dot; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
The method returns a list of lines you can send to graphviz to draw |
46
|
|
|
|
|
|
|
the graph. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__PACKAGE__ |