Skip to content

Instantly share code, notes, and snippets.

@aantonop
Created January 20, 2017 08:25
Show Gist options
  • Save aantonop/20b5b7c151a1d9e37071e0b12a1850fd to your computer and use it in GitHub Desktop.
Save aantonop/20b5b7c151a1d9e37071e0b12a1850fd to your computer and use it in GitHub Desktop.
import graphviz as gv
import sys
import json
graph = gv.Graph(format='svg')
lngraph = json.load(sys.stdin)
for node in lngraph['nodes']:
nodename = node['pub_key'][-6:]
graph.node(nodename)
print "Added {0}".format(nodename)
for edge in lngraph['edges']:
node1 = edge['node1_pub'][-6:]
node2 = edge['node2_pub'][-6:]
graph.edge(node1, node2, label="ch:"+str(edge['channel_id'])[-4:])
print "Added edge {0} <-> {1}".format(node1,node2)
filename = graph.render(filename='lngraph')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment