Skip to content

Instantly share code, notes, and snippets.

View wellington-tinho's full-sized avatar
:electron:
coding all the time

Wellington Rodrigues wellington-tinho

:electron:
coding all the time
View GitHub Profile
@wellington-tinho
wellington-tinho / convert.py
Last active May 6, 2021 17:35 — 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…
import sys
import argparse
import json
import networkx as nx
import community
from networkx.readwrite import json_graph
def graphmltojson(graphfile, outfile):
"""