Skip to content

Instantly share code, notes, and snippets.

@joelhaasnoot
Created December 26, 2011 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelhaasnoot/1521104 to your computer and use it in GitHub Desktop.
Save joelhaasnoot/1521104 to your computer and use it in GitHub Desktop.
from pygraph.classes import graph, exceptions
def make_graph(nodes, edges):
bg = graph.graph()
bg.add_nodes(nodes)
for edge in edges:
try:
bg.add_edge(edge)
except exceptions.AdditionError:
print "Already had it: %s %s" % (edge[0], edge[1]) # Edge is tuple
return bg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment