Modify input file format to be easier to append/maintain
This commit is contained in:
parent
6ba1b97f97
commit
18104d8317
13
polygraph.py
13
polygraph.py
|
@ -22,8 +22,8 @@ gender_colors = {
|
|||
|
||||
# Relationship types... feel free to edit to suit your poly family's needs
|
||||
relationship_colors = {
|
||||
's': 'blue',
|
||||
'd': 'red'
|
||||
'stable': 'blue',
|
||||
'developing': 'red'
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,16 +40,15 @@ def main():
|
|||
graph.edge_attr['arrowsize'] = 0.5
|
||||
|
||||
# Add nodes to graph
|
||||
for user in data:
|
||||
for user in data['members']:
|
||||
graph.add_node(user['name'], fillcolor=gender_colors[user['gender']])
|
||||
|
||||
# Add edges to graph
|
||||
for user1 in data:
|
||||
for (user2, rel, fluid) in user1['connections']:
|
||||
graph.add_edge(user1['name'], user2, style=fluid_colors[fluid], color=relationship_colors[rel])
|
||||
for (member1,member2,rel,fluid) in data['relationships']:
|
||||
graph.add_edge(member1, member2, style=fluid_colors[fluid], color=relationship_colors[rel])
|
||||
|
||||
graph.layout()
|
||||
graph.draw('/tmp/graph.png')
|
||||
graph.draw('poly_network.png')
|
||||
|
||||
|
||||
if __name__ == '__main__': main()
|
||||
|
|
Loading…
Reference in New Issue
Block a user