NAME
Net::GraphSpace - API bindings for GraphSpace
VERSION
version 0.0006
SYNOPSIS
use Net::GraphSpace;
use JSON qw(decode_json);
use Try::Tiny;
my $client = Net::GraphSpace->new(
user => 'bob',
password => 'secret',
host => 'graphspace.org'
);
my $graph = Net::GraphSpace::Graph->new(description => 'yeast ppi');
my $node1 = Net::GraphSpace::Node->new(id => 'node-a', label => 'A');
my $node2 = Net::GraphSpace::Node->new(id => 'node-b', label => 'B');
my $edge = Net::GraphSpace::Edge->new(
id => 'a-b', source => 'node-a', target => 'node-b');
$graph->add_nodes([$node1, $node2]);
$graph->add_edge($edge);
$graph->add_node(Net::GraphSpace::Node->new(id => 3, label => 'C'));
# Upload graph to server and set the graph id
my $graph_id = 'graph-id-1';
my $data = $client->set_graph($graph, $graph_id);
my $url = $data->{url};
# Upload graph to server and have server autogenerate the graph id
$data = $client->add_graph($graph);
$graph_id = $data->{id};
$url = $data->{url};
print "Your graph (id: $graph_id) can be viewed at $url\n";
# Get and update a graph
$graph = $clent->get_graph($graph_id)
or die "Could not find graph $graph_id";
$graph->tags(['foo', 'bar']);
$client->set_graph($graph, $graph_id);
# Delete a graph
try {
$client->delete_graph($graph_id);
print "Deleted graph $graph_id: $_\n";
} catch {
print "Could not delete graph $graph_id: $_\n";
};
DESCRIPTION
Net::GraphSpace provides bindings for the GraphSpace API. GraphSpace is a web based graph/network visualization tool and data store. See http://graphspace.org for more information.
ATTRIBUTES
Required:
- user
- password
- host
Optional:
- port
-
Defaults to 80.
METHODS
new(%params)
Takes key/value arguments corresponding to the attributes above.
get_graph($graph_id)
Returns a Net::GraphSpace::Graph object for the given $graph_id. Returns undef if the graph could not be found.
set_graph($graph, $graph_id)
Creates or updates the graph on the server with id $graph_id. Returns a hashref just like add_graph(). Dies on server error.
add_graph($graph)
Takes a Net::GraphSpace::Graph object and uploads it. Use this method only if you don't care what id is assigned to your graph. Otherwise, use set_graph to create your graph. Returns a hashref of the form:
{
id => 1,
url => 'http://...',
}
The url is the location where the graph can be viewed. Dies on server error.
delete_graph($graph_id)
Deletes the graph with id $graph_id. Returns a true value on success. Dies on failure or if the graph didn't exist.
SEE ALSO
AUTHOR
Naveed Massjouni <naveedm9@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Naveed Massjouni.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.