summaryrefslogtreecommitdiff
path: root/examples/javascript/force.py
diff options
context:
space:
mode:
authorAric Hagberg <aric.hagberg@gmail.com>2012-10-27 09:05:07 -0600
committerAric Hagberg <aric.hagberg@gmail.com>2012-10-27 09:05:07 -0600
commit27269e5b37bfa8899ab565eacc14b2de4dbbd85e (patch)
treed75f5cdf2458c5400925b4d0a9aef4ae3bd29312 /examples/javascript/force.py
parent5e00a123169e453138e3e33d90f40009e8d1c076 (diff)
downloadnetworkx-27269e5b37bfa8899ab565eacc14b2de4dbbd85e.tar.gz
Add a "name" attribute for each node in the force.py example graph.
The force.js example uses the "name" attribute for the mouse-over value.
Diffstat (limited to 'examples/javascript/force.py')
-rw-r--r--examples/javascript/force.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/examples/javascript/force.py b/examples/javascript/force.py
index 74a55492..8784a1c6 100644
--- a/examples/javascript/force.py
+++ b/examples/javascript/force.py
@@ -1,6 +1,6 @@
"""Example of writing JSON format graph data and using the D3 Javascript library to produce an HTML/Javascript drawing.
"""
-# Copyright (C) 2011 by
+# Copyright (C) 2011-2012 by
# Aric Hagberg <hagberg@lanl.gov>
# Dan Schult <dschult@colgate.edu>
# Pieter Swart <swart@lanl.gov>
@@ -13,6 +13,10 @@ from networkx.readwrite import json_graph
import http_server
G = nx.barbell_graph(6,3)
+# this d3 example uses the name attribute for the mouse-hover value,
+# so add a name to each node
+for n in G:
+ G.node[n]['name'] = n
# write json formatted data
d = json_graph.node_link_data(G) # node-link format to serialize
# write json