Created
December 26, 2011 13:14
-
-
Save joelhaasnoot/1521104 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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