-
Notifications
You must be signed in to change notification settings - Fork 38
/
common.pl
74 lines (45 loc) · 1.72 KB
/
common.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/perl -w
#############################################################################
# This script is used by both examples/ascii.pl and examples/html.pl to
# generate some sample graphs and then outputting them in the desired format.
use strict;
use warnings;
BEGIN
{
use lib '../lib';
}
use Graph::Easy;
sub gen_graphs
{
my $graph = shift || Graph::Easy->new();
my $method = shift || 'ascii';
###########################################################################
my $node = $graph->add_node( 'Bonn' );
my $node2 = $graph->add_node( 'Berlin' );
$graph->add_edge( $node, $node2 );
out ($graph, $method);
###########################################################################
$graph->{debug} = 0;
my $node3 = $graph->add_node( 'Frankfurt' );
$node3->set_attribute('border-style', 'dotted');
my $edge3 = Graph::Easy::Edge->new( style => 'double' );
$graph->add_edge( $node2, $node3, $edge3 );
out ($graph, $method);
###########################################################################
$graph->add_edge( $node3, 'Dresden' );
out ($graph, $method);
###########################################################################
$graph->add_edge( $node2, 'Potsdam' );
out ($graph, $method);
###########################################################################
my $node6 = $graph->add_node( 'Cottbus',);
$node6->set_attribute('border', '1px red dashed');
my $edge5 = $graph->add_edge( 'Potsdam', $node6 );
out ($graph, $method);
###########################################################################
$graph->add_edge( $node6, $node3 );
out ($graph, $method);
$graph->add_edge( $node6, $node3 );
out ($graph, $method);
}
1;