line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Graph::Writer::DrGeo; |
2
|
1
|
|
|
1
|
|
818
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
468
|
use Graph::Writer; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use vars qw(@ISA $VERSION); |
6
|
|
|
|
|
|
|
@ISA = qw(Graph::Writer); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Math::Trig qw(:radial deg2rad pi); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$VERSION = '0.01'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $layout = 'circle'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub _write_graph { |
15
|
|
|
|
|
|
|
my ($self,$graph,$FILE) = @_; |
16
|
|
|
|
|
|
|
my @V = $graph->vertices_unsorted; |
17
|
|
|
|
|
|
|
my $out = "(new-figure \"Graph\")\n"; |
18
|
|
|
|
|
|
|
for my $i (0..$#V) { |
19
|
|
|
|
|
|
|
my ($x,$y) = calc_circle_dot_position($i,scalar(@V)); |
20
|
|
|
|
|
|
|
$out .= qq{(lets Point "$V[$i]" free $x $y)\n}; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my @E = $graph->edges; |
24
|
|
|
|
|
|
|
for my $i (0..@E/2) { |
25
|
|
|
|
|
|
|
my $V1 = @E[2*$i] || last; |
26
|
|
|
|
|
|
|
my $V2 = @E[2*$i + 1] || last; |
27
|
|
|
|
|
|
|
$out .= qq{(Segment "" extremities $V1 $V2)\n}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
print $FILE $out; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub calc_circle_dot_position { |
33
|
|
|
|
|
|
|
my ($n,$ndots) = @_; |
34
|
|
|
|
|
|
|
# 3 is just a random estimation, should have a better guess. |
35
|
|
|
|
|
|
|
my $rho = $ndots/3; |
36
|
|
|
|
|
|
|
my ($x,$y) = raid2cart($rho,deg2rad(360*$n/$ndots)); |
37
|
|
|
|
|
|
|
return ($x,$y); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub raid2cart { |
41
|
|
|
|
|
|
|
my ($rho,$theta) = @_; |
42
|
|
|
|
|
|
|
my ($x,$y) = spherical_to_cartesian($rho,$theta,pi/2); |
43
|
|
|
|
|
|
|
return ($x,$y); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
__END__ |