Skip to content

Instantly share code, notes, and snippets.

@danlamanna
Created September 10, 2015 17:59
Show Gist options
  • Save danlamanna/3302ae595f4d5b4d3073 to your computer and use it in GitHub Desktop.
Save danlamanna/3302ae595f4d5b4d3073 to your computer and use it in GitHub Desktop.
import json
import networkx as nx
import romanesco
betweenness_centrality = {
'inputs': [
{'name': 'G',
'type': 'graph',
'format': 'networkx'},
{'name': 'node',
'type': 'string',
'format': 'text'}
],
'outputs': [
{'name': 'measure',
'type': 'number',
'format': 'number'}
],
'script':
'''
from networkx import betweenness_centrality
measure = betweenness_centrality(G)[node]
'''
}
with open('/home/dan/Downloads/alphabet-network.json', 'rb') as infile:
clique_graph = infile.read()
output = romanesco.run(betweenness_centrality, inputs={'G': {'format': 'clique.json',
'data': clique_graph},
'node': {'format': 'text',
'data': '55ba5019f8883b5bf35f3e30'}})
print output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment