summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2011-05-21 15:07:05 +0200
committerfranck cuny <franck@lumberjaph.net>2011-05-21 15:07:05 +0200
commit2694cc20cd3a47d6eb84a2f4843ef2ba5afbd35c (patch)
tree749b1dfdcea851b0e814ea780b9a5d7723b480a7 /lib
parentadd new roles to handle all the viz elements (diff)
downloadgraph-gexf-2694cc20cd3a47d6eb84a2f4843ef2ba5afbd35c.tar.gz
perltidy
Signed-off-by: franck cuny <franck@lumberjaph.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/Graph/GEXF.pm39
1 files changed, 27 insertions, 12 deletions
diff --git a/lib/Graph/GEXF.pm b/lib/Graph/GEXF.pm
index be65219..46b585a 100644
--- a/lib/Graph/GEXF.pm
+++ b/lib/Graph/GEXF.pm
@@ -11,41 +11,56 @@ use Graph::GEXF::Node;
 
 with
   'Graph::GEXF::Role::XML',
-  'Graph::GEXF::Role::Attributes' => {for => [qw/node edge/], with_method => 1};
+  'Graph::GEXF::Role::Attributes' =>
+  { for => [qw/node edge/], with_method => 1 };
 
 has graph_mode => (
     is       => 'ro',
-    isa      => enum([qw/static dynamic/]),
+    isa      => enum( [qw/static dynamic/] ),
     required => 1,
     default  => 'static',
 );
 
 has edge_type => (
     is       => 'ro',
-    isa      => enum([qw/directed undirected mutual notset/]),
+    isa      => enum( [qw/directed undirected mutual notset/] ),
     required => 1,
     default  => 'directed',
 );
 
 has nodes => (
-    traits  => ['Hash'],
-    is      => 'rw',
-    isa     => 'HashRef[Graph::GEXF::Node]',
-    default => sub { {} },
-    auto_deref=> 1,
-    handles => {
+    traits     => ['Hash'],
+    is         => 'rw',
+    isa        => 'HashRef[Graph::GEXF::Node]',
+    default    => sub { {} },
+    auto_deref => 1,
+    handles    => {
         _node_exists => 'exists',
         _add_node    => 'set',
         total_nodes  => 'count',
-        get_node => 'get',
-        all_nodes => 'keys',
+        get_node     => 'get',
+        all_nodes    => 'keys',
     },
 );
 
 sub add_node {
-    my ($self, $id) = @_;
+    my $self = shift;
+    my ($id, %attributes);
 
     # TODO should be possible to add a Graph::GEXF::Node too
+    
+    if ( @_ == 1 ) {
+        $id = shift;
+    }
+    else {
+        if ( ( @_ % 2 ) == 0 ) {
+            %attributes = @_;
+        }
+        else {
+            $id = shift;
+            %attributes = @_;
+        }
+    }
 
     if ($id && $self->_node_exists($id)) {
         die "Can't add node wih id $id: already exists";