Skip to content

Instantly share code, notes, and snippets.

View charan223's full-sized avatar

Charan charan223

View GitHub Profile
@charan223
charan223 / convert.py
Created October 18, 2016 11:03 — forked from anderser/convert.py
Convert from NodeXL (via GraphML-format) to D3-ready json for force layout while adding modularity groups (communities) as attribute to nodes. Useful for coloring nodes via modularitygroup attribute. Requires networkx and python-louvain. First export as GraphML file from your NodeXL-sheet. Then run: >>> python convert.py -i mygraph.graphml -o ou…
#!/usr/bin/env python
import sys
import argparse
import networkx as nx
import community
from networkx.readwrite import json_graph
def graphmltojson(graphfile, outfile):