From faf6949033a021bffab3c91a04665efef4378b28 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Fri, 16 Jul 2010 11:19:15 +0200 Subject: basic gexf generation --- t/01-basic.t | 12 ++++++++++++ t/02-graph.t | 18 ++++++++++++++++++ t/03-node.t | 19 +++++++++++++++++++ t/04-edges.t | 7 +++++++ t/05-basic_graph.t | 20 ++++++++++++++++++++ t/06-data.t | 33 +++++++++++++++++++++++++++++++++ 6 files changed, 109 insertions(+) create mode 100644 t/01-basic.t create mode 100644 t/02-graph.t create mode 100644 t/03-node.t create mode 100644 t/04-edges.t create mode 100644 t/05-basic_graph.t create mode 100644 t/06-data.t (limited to 't') diff --git a/t/01-basic.t b/t/01-basic.t new file mode 100644 index 0000000..8e1a231 --- /dev/null +++ b/t/01-basic.t @@ -0,0 +1,12 @@ +use strict; +use warnings; +use Test::More; +use Graph::GEXF; + +ok my $graph = Graph::GEXF->new(), 'graph created'; +ok my $n1 = $graph->add_node(), 'node created'; +ok $n1->id, 'node has an id'; +is $graph->total_nodes, 1, 'got one node'; +ok my $n2 = $graph->get_node($n1->id); + +done_testing; diff --git a/t/02-graph.t b/t/02-graph.t new file mode 100644 index 0000000..a81f889 --- /dev/null +++ b/t/02-graph.t @@ -0,0 +1,18 @@ +use strict; +use warnings; + +use Test::More; + +use Graph::GEXF; + +ok my $graph = Graph::GEXF->new(), 'graph created'; + +$graph->add_node_attribute('url', 'anyURI'); +$graph->add_node_attribute('lf', 'integer'); + +is $graph->total_attributes, 2, 'got 2 attributes'; + +ok my $attr = $graph->get_attribute('url'), 'fetch first attribute'; +is $attr->{title}, 'url', 'first attribute is url'; + +done_testing; diff --git a/t/03-node.t b/t/03-node.t new file mode 100644 index 0000000..ccd79fe --- /dev/null +++ b/t/03-node.t @@ -0,0 +1,19 @@ +use strict; +use warnings; +use Test::More; + +use Graph::GEXF::Node; + +ok my $node = Graph::GEXF::Node->new(id =>0), 'node created'; + +ok !$node->attribute('url', 'http://linkfluence.net'), 'can\'t add attribute, not attributes defined'; + +ok $node = Graph::GEXF::Node->new( + id => 0, + attributes => {url => {title => 'url', type => 'anyURI'}} + ), + 'node created'; + +ok $node->attribute('url', 'http://linkfluence.net'), 'add attribute url to node'; + +done_testing; diff --git a/t/04-edges.t b/t/04-edges.t new file mode 100644 index 0000000..9ded831 --- /dev/null +++ b/t/04-edges.t @@ -0,0 +1,7 @@ +use strict; +use warnings; +use Test::More; + +ok 1; + +done_testing; diff --git a/t/05-basic_graph.t b/t/05-basic_graph.t new file mode 100644 index 0000000..ed1a921 --- /dev/null +++ b/t/05-basic_graph.t @@ -0,0 +1,20 @@ +use strict; +use warnings; +use Test::More; + +use Graph::GEXF; + +my $graph = Graph::GEXF->new(); + +my $n1 = $graph->add_node; +$n1->label('hello'); + +my $n2 = $graph->add_node; +$n2->label('world'); + +$n1->link_to($n2->id); + +ok my $xml = $graph->to_xml; +#print $xml; + +done_testing; diff --git a/t/06-data.t b/t/06-data.t new file mode 100644 index 0000000..f9f2ea2 --- /dev/null +++ b/t/06-data.t @@ -0,0 +1,33 @@ +use strict; +use warnings; +use Test::More; + +use Graph::GEXF; + +my $graph = Graph::GEXF->new(); +$graph->add_node_attribute('url', 'string'); +$graph->add_node_attribute('indegree', 'float'); +$graph->add_node_attribute('frog', 'boolean'); + +my $n1 = $graph->add_node(0); +$n1->label('Gephi'); +$n1->link_to(1, 2, 3); +$n1->attribute('url' => 'http://gephi.org/'); + +my $n2 = $graph->add_node(1); +$n2->label('WebAtlas'); +$n2->link_to(0); +$n2->attribute('url' => 'http://webatlas.fr/'); + +my $n3 = $graph->add_node(2); +$n3->label('RTGI'); +$n3->link_to(1); + +my $n4 = $graph->add_node(3); +$n4->label('BarabasiLab'); + +ok my $xml = $graph->to_xml; + +print $xml; + +done_testing; -- cgit v1.2.3