Skip to content

Instantly share code, notes, and snippets.

@xmichaelx
Created December 9, 2014 02:09
Show Gist options
  • Select an option

  • Save xmichaelx/9d470ba3324a0a756fa8 to your computer and use it in GitHub Desktop.

Select an option

Save xmichaelx/9d470ba3324a0a756fa8 to your computer and use it in GitHub Desktop.
import snap
# requires python 2.7 and 64-bit machine
G1 = snap.TUNGraph.New()
with open("data/edges.csv") as f:
for line in f:
tokens = line.split()
n1, n2, weight = int(tokens[0]), int(tokens[1]), int(tokens[2])
if not G1.IsNode(n1):
G1.AddNode(n1)
if not G1.IsNode(n2):
G1.AddNode(n2)
G1.AddEdge(n1, n2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment