Last active
October 4, 2015 23:09
-
-
Save mag5323/e5ad752b0e7df52f586b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from networkx import * | |
from networkx.readwrite import json_graph | |
# gnp_random_graph(Nodes, Probability for edge creation) | |
G = gnp_random_graph(10, 0.4) | |
Degrees = G.degree() | |
MaxDeg = max(Degrees, key=Degrees.get) | |
Neighbors = G.neighbors(MaxDeg) | |
JsonG = json_graph.node_link_data(G) | |
# Coloring max deg and it's neighbors | |
JsonG['nodes'][MaxDeg]['group'] = 1 | |
for node in Neighbors: | |
JsonG['nodes'][node]['group'] = 1 | |
json.dump(JsonG, open('output.json', 'w')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment