| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# Graph::Writer::TGXML - write a directed graph out as TouchGraph LinkBrowser XML |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# $Id$ |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
package Graph::Writer::TGXML; |
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
223700
|
use strict; |
|
|
2
|
|
|
|
|
12
|
|
|
|
2
|
|
|
|
|
58
|
|
|
9
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
51
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
778
|
use Graph::Writer; |
|
|
2
|
|
|
|
|
22054
|
|
|
|
2
|
|
|
|
|
60
|
|
|
12
|
2
|
|
|
2
|
|
1155
|
use XML::Writer; |
|
|
2
|
|
|
|
|
14251
|
|
|
|
2
|
|
|
|
|
58
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
12
|
use vars qw(@ISA $VERSION); |
|
|
2
|
|
|
|
|
97
|
|
|
|
2
|
|
|
|
|
683
|
|
|
15
|
|
|
|
|
|
|
$VERSION = 0.03; |
|
16
|
|
|
|
|
|
|
@ISA = qw(Graph::Writer); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#======================================================================= |
|
20
|
|
|
|
|
|
|
# |
|
21
|
|
|
|
|
|
|
# _write_graph() - perform the writing of the graph |
|
22
|
|
|
|
|
|
|
# |
|
23
|
|
|
|
|
|
|
# This is invoked from the public write_graph() method, |
|
24
|
|
|
|
|
|
|
# and is where the actual writing of the graph happens. |
|
25
|
|
|
|
|
|
|
# |
|
26
|
|
|
|
|
|
|
# Basically we start a graph element then: |
|
27
|
|
|
|
|
|
|
# [] dump out any attributes of the graph |
|
28
|
|
|
|
|
|
|
# [] dump out all vertices, with any attributes of each vertex |
|
29
|
|
|
|
|
|
|
# [] dump out all edges, with any attributes of each edge |
|
30
|
|
|
|
|
|
|
# And then close the graph element. Ta da! |
|
31
|
|
|
|
|
|
|
# |
|
32
|
|
|
|
|
|
|
#======================================================================= |
|
33
|
|
|
|
|
|
|
sub _write_graph |
|
34
|
|
|
|
|
|
|
{ |
|
35
|
1
|
|
|
1
|
|
653
|
my $self = shift; |
|
36
|
1
|
|
|
|
|
2
|
my $graph = shift; |
|
37
|
1
|
|
|
|
|
2
|
my $FILE = shift; |
|
38
|
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
4
|
my $v; |
|
40
|
|
|
|
|
|
|
my $from; |
|
41
|
1
|
|
|
|
|
0
|
my $to; |
|
42
|
|
|
|
|
|
|
# my %attributes; |
|
43
|
1
|
|
|
|
|
0
|
my $xmlwriter; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
7
|
$xmlwriter = XML::Writer->new(OUTPUT => $FILE, |
|
47
|
|
|
|
|
|
|
DATA_MODE => 1, |
|
48
|
|
|
|
|
|
|
DATA_INDENT => 2); |
|
49
|
1
|
|
|
|
|
218
|
$xmlwriter->setOutput($FILE); |
|
50
|
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
39
|
$xmlwriter->startTag('TOUCHGRAPH_LB', version => '1.20'); |
|
52
|
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
120
|
$xmlwriter->startTag('NODESET'); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
#------------------------------------------------------------------- |
|
56
|
|
|
|
|
|
|
# dump out vertices of the graph, including any attributes |
|
57
|
|
|
|
|
|
|
#------------------------------------------------------------------- |
|
58
|
1
|
|
|
|
|
53
|
foreach $v (sort { $a cmp $b } ($graph->vertices)) |
|
|
5
|
|
|
|
|
79
|
|
|
59
|
|
|
|
|
|
|
{ |
|
60
|
4
|
|
50
|
|
|
107
|
my $attributes = $graph->get_vertex_attributes($v) || {}; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# print ">$v<\n"; |
|
63
|
|
|
|
|
|
|
|
|
64
|
4
|
|
|
|
|
474
|
$xmlwriter->startTag('NODE', 'nodeID' => $v); |
|
65
|
4
|
|
|
|
|
303
|
$xmlwriter->emptyTag('NODE_LOCATION', |
|
66
|
|
|
|
|
|
|
x => 633, |
|
67
|
|
|
|
|
|
|
y => 30, |
|
68
|
|
|
|
|
|
|
visible => 'true' ); |
|
69
|
|
|
|
|
|
|
$xmlwriter->emptyTag('NODE_LABEL', |
|
70
|
4
|
|
33
|
|
|
474
|
label => $attributes->{label} || $v, |
|
71
|
|
|
|
|
|
|
shape => 2, |
|
72
|
|
|
|
|
|
|
backColor => 'FFFFFF', |
|
73
|
|
|
|
|
|
|
textColor => '000000', |
|
74
|
|
|
|
|
|
|
fontSize => 16 ); |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$xmlwriter->emptyTag('NODE_URL', |
|
77
|
4
|
|
50
|
|
|
601
|
url => $attributes->{URL} || '', |
|
78
|
|
|
|
|
|
|
urlIsLocal => 'false', |
|
79
|
|
|
|
|
|
|
urlIsXML =>'false' ); |
|
80
|
|
|
|
|
|
|
|
|
81
|
4
|
|
50
|
|
|
441
|
$attributes->{tooltip} ||= ''; |
|
82
|
4
|
|
|
|
|
9
|
$attributes->{tooltip} =~ s/\\74/
|
|
83
|
4
|
|
|
|
|
6
|
$attributes->{tooltip} =~ s/\\76/>/g; |
|
84
|
|
|
|
|
|
|
$xmlwriter->emptyTag('NODE_HINT', |
|
85
|
4
|
|
50
|
|
|
24
|
hint => $attributes->{tooltip} || '', |
|
86
|
|
|
|
|
|
|
width => 400, |
|
87
|
|
|
|
|
|
|
height => -1, |
|
88
|
|
|
|
|
|
|
isHTML => 'false' ); |
|
89
|
4
|
|
|
|
|
511
|
$xmlwriter->endTag('NODE'); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
31
|
$xmlwriter->endTag('NODESET'); |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
#------------------------------------------------------------------- |
|
95
|
|
|
|
|
|
|
# dump out edges of the graph, including any attributes |
|
96
|
|
|
|
|
|
|
#------------------------------------------------------------------- |
|
97
|
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
31
|
$xmlwriter->startTag('EDGESET'); |
|
99
|
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
49
|
my @edges = $graph->edges; |
|
101
|
1
|
|
|
|
|
30
|
while (@edges) |
|
102
|
|
|
|
|
|
|
{ |
|
103
|
0
|
|
|
|
|
0
|
($from, $to) = splice(@edges, 0, 2); |
|
104
|
|
|
|
|
|
|
# my $attributes = $graph->get_edge_attributes($from, $to); |
|
105
|
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
0
|
$xmlwriter->emptyTag('EDGE', |
|
107
|
|
|
|
|
|
|
fromID => $from, |
|
108
|
|
|
|
|
|
|
toID => $to, |
|
109
|
|
|
|
|
|
|
type => 1, |
|
110
|
|
|
|
|
|
|
length => 40, |
|
111
|
|
|
|
|
|
|
visible => 'true', |
|
112
|
|
|
|
|
|
|
color => 'A0A0A0' ); |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
12
|
$xmlwriter->endTag('EDGESET'); |
|
117
|
|
|
|
|
|
|
|
|
118
|
1
|
|
|
|
|
26
|
$xmlwriter->endTag('TOUCHGRAPH_LB'); |
|
119
|
1
|
|
|
|
|
31
|
$xmlwriter->end(); |
|
120
|
|
|
|
|
|
|
|
|
121
|
1
|
|
|
|
|
100
|
return 1; |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
__END__ |