line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package String::Eertree::ToDot; |
2
|
1
|
|
|
1
|
|
252249
|
use Moo; |
|
1
|
|
|
|
|
12704
|
|
|
1
|
|
|
|
|
6
|
|
3
|
|
|
|
|
|
|
extends 'String::Eertree'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub to_dot { |
6
|
1
|
|
|
1
|
0
|
9
|
my ($self) = @_; |
7
|
1
|
|
|
|
|
3
|
my @lines = ('digraph { rankdir = BT;'); |
8
|
1
|
|
|
|
|
6
|
for my $i (0 .. $self->Last) { |
9
|
9
|
|
|
|
|
21
|
my $node = $self->node($i); |
10
|
9
|
|
100
|
|
|
26
|
push @lines, qq($i [shape=record, label="$i|) |
11
|
|
|
|
|
|
|
. ($node->string($self) || $i - 1) . '"]'; |
12
|
9
|
|
|
|
|
33
|
push @lines, $i . '->' . $node->link . '[color=blue]'; |
13
|
|
|
|
|
|
|
} |
14
|
1
|
|
|
|
|
5
|
for my $i (0 .. $self->Last) { |
15
|
9
|
|
|
|
|
73
|
my $node = $self->node($i); |
16
|
9
|
|
|
|
|
14
|
for my $ch (sort keys %{ $node->edge }) { |
|
9
|
|
|
|
|
145
|
|
17
|
7
|
|
|
|
|
168
|
push @lines, $i . '->' . $node->edge->{$ch} |
18
|
|
|
|
|
|
|
. "[label=$ch, constraint=false]"; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
} |
21
|
1
|
|
|
|
|
3
|
push @lines, '}'; |
22
|
|
|
|
|
|
|
return @lines |
23
|
1
|
|
|
|
|
85
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
String::Eertree::ToDot - Draw the Eertree graph using graphviz |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 VERSION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Version 0.02 |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
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__ |