Skip to content

Instantly share code, notes, and snippets.

@PaulCapestany
Forked from aantonop/lngraph.py
Created December 14, 2017 22:02
Show Gist options
  • Save PaulCapestany/643c509526211d3e099486852a841668 to your computer and use it in GitHub Desktop.
Save PaulCapestany/643c509526211d3e099486852a841668 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