Skip to content

Instantly share code, notes, and snippets.

@justquick
Created November 11, 2009 20:59
Show Gist options
  • Save justquick/232291 to your computer and use it in GitHub Desktop.
Save justquick/232291 to your computer and use it in GitHub Desktop.
import csv
import yapgvb
graph = yapgvb.Digraph('OriginalZombie')
rows = list(csv.DictReader(open('players.csv')))
def get_victims(id):
for row in rows:
if id == row['killed_by']:
yield row
def gen(killer=None, parent=None):
if killer is None:
killer = {'id':'OriginalZombie'}
if parent is None:
parent = graph.add_node('OZ',label='OriginalZombie')
for vic in get_victims(killer['id']):
node = graph.add_node(vic['id'], label=vic['fname'], shape='record')
parent >> node
gen(vic, node)
gen()
graph.layout(yapgvb.engines.dot)
graph.render('players.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment