Skip to content

Instantly share code, notes, and snippets.

@aahoo
Last active December 6, 2015 11:51
Show Gist options
  • Save aahoo/b3bd940344c0401454d5 to your computer and use it in GitHub Desktop.
Save aahoo/b3bd940344c0401454d5 to your computer and use it in GitHub Desktop.
from networkx.readwrite import json_graph
import json
# Return data in adjacency format that is suitable for
# JSON serialization and use in Javascript documents.
# more @https://goo.gl/QoRlbL
data = json_graph.adjacency_data(G)
with codecs.open('matrix.json', 'w', encoding='utf-8') as f:
json.dump(data, f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment