| 1 | package Language::Homespring::Visualise::GraphViz; | ||||||||||||
| 2 | |||||||||||||
| 3 | 1 | $VERSION = 0.04; | |||||||||||
| 4 | |||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 1 | ▶ | use GraphViz; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | |||||||||||||
| 9 | 0 | ▶ | sub new { | ||||||||||
|
Subroutine
new: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||
| 10 | 0 | my $class = shift; | |||||||||||
| 11 | 0 | my $self = bless {}, $class; | |||||||||||
| 12 | |||||||||||||
| 13 | 0 | my $options = shift; | |||||||||||
| 14 | 0 | $self->{interp} = $options->{interp}; | |||||||||||
| 15 | 0 | ▶ | $self->{spring_col} = $options->{spring_col} || '#C0C0FF'; | ||||||||||
|
Condition0%0/2
$options->{'spring_col'} || '#C0C0FF'
MC/DC0%0/1
$options->{'spring_col'} || '#C0C0FF'
$options->{'spring_col'}
Truth table0%0/2
A
A= $options->{'spring_col'}
| |||||||||||||
| 16 | 0 | ▶ | $self->{node_col} = $options->{node_col} || 'white'; | ||||||||||
|
Condition0%0/2
$options->{'node_col'} || 'white'
MC/DC0%0/1
$options->{'node_col'} || 'white'
$options->{'node_col'}
Truth table0%0/2
A
A= $options->{'node_col'}
| |||||||||||||
| 17 | |||||||||||||
| 18 | 0 | ▶ | $self->{fontname} = $options->{fontname} || 'Times'; | ||||||||||
|
Condition0%0/2
$options->{'fontname'} || 'Times'
MC/DC0%0/1
$options->{'fontname'} || 'Times'
$options->{'fontname'}
Truth table0%0/2
A
A= $options->{'fontname'}
| |||||||||||||
| 19 | 0 | ▶ | $self->{fontsize} = $options->{fontsize} || '12'; | ||||||||||
|
Condition0%0/2
$options->{'fontsize'} || '12'
MC/DC0%0/1
$options->{'fontsize'} || '12'
$options->{'fontsize'}
Truth table0%0/2
A
A= $options->{'fontsize'}
| |||||||||||||
| 20 | |||||||||||||
| 21 | 0 | return $self; | |||||||||||
| 22 | } | ||||||||||||
| 23 | |||||||||||||
| 24 | 0 | ▶ | sub do { | ||||||||||
|
Subroutine
do: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 25 | 0 | my ($self) = @_; | |||||||||||
| 26 | |||||||||||||
| 27 | 0 | $self->{graph} = GraphViz->new( | |||||||||||
| 28 | directed => 0, | ||||||||||||
| 29 | layout => 'dot', | ||||||||||||
| 30 | rankdir => 1, | ||||||||||||
| 31 | epsilon => 1, | ||||||||||||
| 32 | ); | ||||||||||||
| 33 | |||||||||||||
| 34 | 0 | $self->add_node($self->{interp}->{root_node}, 1); | |||||||||||
| 35 | |||||||||||||
| 36 | 0 | return $self->{graph}; | |||||||||||
| 37 | } | ||||||||||||
| 38 | |||||||||||||
| 39 | 0 | ▶ | sub add_node { | ||||||||||
|
Subroutine
add_node: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||
| 40 | 0 | my ($self, $node, $rank) = @_; | |||||||||||
| 41 | |||||||||||||
| 42 | 0 | for(@{$node->{child_nodes}}){ | |||||||||||
| 43 | 0 | my $label = $_->{node_name_safe}; | |||||||||||
| 44 | 0 | $label =~ s/\\/\\\\/g; | |||||||||||
| 45 | |||||||||||||
| 46 | 0 | ▶ | my $fillcolor = $_->{spring}?$self->{spring_col}:$self->{node_col}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 47 | |||||||||||||
| 48 | $self->{graph}->add_node( | ||||||||||||
| 49 | $_->{uid}, | ||||||||||||
| 50 | label => $label, | ||||||||||||
| 51 | rank => $rank, | ||||||||||||
| 52 | fillcolor => $fillcolor, | ||||||||||||
| 53 | style => 'filled', | ||||||||||||
| 54 | fontname => $self->{fontname}, | ||||||||||||
| 55 | fontsize => $self->{fontsize}, | ||||||||||||
| 56 | 0 | ); | |||||||||||
| 57 | |||||||||||||
| 58 | $self->{graph}->add_edge( | ||||||||||||
| 59 | $node->{uid} => $_->{uid}, | ||||||||||||
| 60 | arrowtail => 'normal', | ||||||||||||
| 61 | 0 | ▶ | ) if ($node->{uid} != $self->{interp}->{root_node}->{uid}); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 62 | |||||||||||||
| 63 | 0 | $self->add_node($_, $rank+1); | |||||||||||
| 64 | } | ||||||||||||
| 65 | } | ||||||||||||
| 66 | |||||||||||||
| 67 | __END__ | ||||||||||||