Created
November 11, 2009 20:59
-
-
Save justquick/232291 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
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