Skip to content

Commit

Permalink
allow input network to be a node-link dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
ulfaslak committed Apr 11, 2019
1 parent 4647904 commit 58906f7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions netwulf/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def visualize(network,
Parameters
----------
network : networkx.Graph or networkx.DiGraph
network : networkx.Graph or networkx.DiGraph or node-link dictionary
The network to visualize
port : int, default : 9853
The port at which to run the server locally.
Expand Down Expand Up @@ -246,7 +246,10 @@ def visualize(network,
configpath = os.path.join(web_dir, configname)

with open(filepath,'w') as f:
json.dump(nx.node_link_data(network), f, iterable_as_array=True)
if type(network) is nx.Graph:
json.dump(nx.node_link_data(network), f, iterable_as_array=True)
else:
json.dump(network, f, iterable_as_array=True)

with open(configpath,'w') as f:
json.dump(this_config, f)
Expand Down

0 comments on commit 58906f7

Please sign in to comment.