In [8]:
import pandas as pd
import graphistry
#graphistry.register('PUT API KEY HERE', server='labs.graphistry.com') #https://www.graphistry.com/api-request
In [9]:
import json
import urllib2
data = urllib2.urlopen('https://raw.githubusercontent.com/adrianco/spigo/master/json/cassandra9.json')
data = json.load(data)[u'graph']
nodes = pd.DataFrame([x for x in data if u'node' in x])
edges = pd.DataFrame([x for x in data if u'edge' in x])
data[:3]
Out[9]:
In [10]:
nodes[:3]
Out[10]:
In [11]:
edges[:3]
Out[11]:
In [12]:
# Plot graph using the source/target columns as source/destination of edges
g = graphistry.bind(source='source', destination='target').bind(node='node')
g.nodes(nodes).edges(edges).plot()
Out[12]:
In [13]:
hg = graphistry.hypergraph(
pd.concat([nodes, edges], ignore_index=True),
['metadata', 'node', 'package', 'source', 'target'],
direct=True,
opts={
'CATEGORIES': {
'service': ['node', 'source', 'target']
}
})
hg['graph'].plot()
Out[13]:
In [ ]: