GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
SpringGraph(3) User Contributed Perl Documentation SpringGraph(3)

SpringGraph - Directed Graph alternative to GraphViz

use SpringGraph qw(calculate_graph draw_graph);

## object oriented interface ##

my $graph = new SpringGraph;

# add a node to the graph (with optional label)

$graph->add_node('Paris', label =>'City of Love');

# add an edge to the graph (with optional label, and directed)

$graph->add_edge('London' => 'New York', label => 'Far', dir=>1);

# output the graph to a file

$graph->as_png($filename);

# get the graph as GD image object

$graph->as_gd;

## procedural interface ##

my %node = ( london => { label => 'London (Waterloo)'}, paris => { label => 'Paris' }, brussels => { label => 'Brussels'}, );

my %link = ( london => { paris => {style => 'dotted'}, 'new york' => {} }, # non-directed, dotted and plain lines paris => { brussels => { dir => 1} }, # directed from paris to brussels );

my $graph = calculate_graph(\%node,\%link);

draw_graph($filename,\%node,\%link);

SpringGraph.pm is a rewrite of the springgraph.pl script, which provides similar functionality to Neato and can read some/most dot files.

The goal of this module is to provide a compatible interface to VCG and/or GraphViz perl modules on CPAN. This module will also provide some extra features to provide more flexibility and power.

Constructor for the class, returns a new SpringGraph object

my $graph = SpringGraph->new;

returns a hashref of the nodes in the graph, populated with coordinates

my $graph = calculate_graph(\%node,\%link);

outputs the graph as a png file either to the file specified by the filename or to STDOUT

takes filename, hashref of nodes and list of edges

draw_graph($filename,\%node,\%link);

adds a node to a graph

takes the name of the node and any attributes such as label

# just like GraphViz.pm :) $graph->add_node('Paris', label =>'City of Love');

adds an edge to a graph

takes the source and destination of the edge and attributes such as style (dotted or dashed), or if the line is directed or not

$graph->add_edge('London' => 'New York', dir => 1, style=>'dashed');

prints the image of the graph in PNG format

takes an optional filename or outputs directly to STDOUT

$graph->as_png($filename);

returns the GD image object of the graph

my $gd_im = $graph->as_gd;

returns the image of the graph in a string in the format specified or PNG

my $graph_png = $graph->as_image('png');

GraphViz

springgraph.pl

http://www.chaosreigns.com/code/springgraph/

GD

Aaron Trevena, based on original script by 'Darxus'

Original Copyright 2002 Darxus AT ChaosReigns DOT com

Amendments and further development copyright 2004 Aaron Trevena

This software is free software. It is made available and licensed under the GNU GPL.

2004-07-16 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.