Mercurial > sypikslang
diff gamelib/visualize.py @ 149:e49f2dba0ad4
More visualization wrangling.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Fri, 11 May 2012 17:13:28 +0200 |
parents | 2587f8c34f84 |
children |
line wrap: on
line diff
--- a/gamelib/visualize.py Fri May 11 16:39:17 2012 +0200 +++ b/gamelib/visualize.py Fri May 11 17:13:28 2012 +0200 @@ -5,7 +5,7 @@ COLORS = { 'schematic': 'green', - 'research': 'pink', + 'research': 'blue', } @@ -14,13 +14,15 @@ def add_node(rt, science): - rt.add_node(science, label=science.NAME, color=color(science)) + rt.add_node(science, label=science.NAME, color=color(science), + group=science.NAME, fillcolor='light' + color(science), + style='filled') def add_pre_node(rt, prior, science, points): name = "%s%s" % (science.NAME[:3], points) if name not in rt: - rt.add_node(name, color=color(science)) + rt.add_node(name, color=color(science), group=science.NAME) rt.add_edge(prior, name, color=color(science)) return name @@ -33,13 +35,18 @@ rt.add_edge(prior, science, color=color(science)) -def construct_research_tree(lab): - rt = networkx.DiGraph() - sciences = lab.new_research + lab.new_schematics +def graph_sciences(rt, sciences): for science in sciences: add_node(rt, science) for science in sciences: add_prereqs(rt, science) + + +def construct_research_tree(lab): + rt = networkx.DiGraph() + # We do these separately for a better layout. + graph_sciences(rt, lab.new_research) + graph_sciences(rt, lab.new_schematics) return rt