line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package String::Eertree::ToDot; |
2
|
1
|
|
|
1
|
|
243512
|
use Moo; |
|
1
|
|
|
|
|
11675
|
|
|
1
|
|
|
|
|
5
|
|
3
|
|
|
|
|
|
|
extends 'String::Eertree'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub to_dot { |
6
|
1
|
|
|
1
|
0
|
8
|
my ($self) = @_; |
7
|
1
|
|
|
|
|
4
|
my @lines = ('digraph { rankdir = BT;'); |
8
|
1
|
|
|
|
|
4
|
for my $i (0 .. $self->Last) { |
9
|
9
|
|
|
|
|
31
|
my $node = $self->node($i); |
10
|
9
|
|
100
|
|
|
35
|
push @lines, qq($i [shape=record, label="$i|) |
11
|
|
|
|
|
|
|
. ($node->string($self) || $i - 1) . '"]'; |
12
|
9
|
|
|
|
|
34
|
push @lines, $i . '->' . $node->link . '[color=blue]'; |
13
|
|
|
|
|
|
|
} |
14
|
1
|
|
|
|
|
4
|
for my $i (0 .. $self->Last) { |
15
|
9
|
|
|
|
|
68
|
my $node = $self->node($i); |
16
|
9
|
|
|
|
|
13
|
for my $ch (sort keys %{ $node->edge }) { |
|
9
|
|
|
|
|
153
|
|
17
|
7
|
|
|
|
|
159
|
push @lines, $i . '->' . $node->edge->{$ch} |
18
|
|
|
|
|
|
|
. "[label=$ch, constraint=false]"; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
} |
21
|
1
|
|
|
|
|
3
|
push @lines, '}'; |
22
|
|
|
|
|
|
|
return @lines |
23
|
1
|
|
|
|
|
37
|
} |
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__ |