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 types... feel free to edit to suit your poly family's needs
|
||||||
relationship_colors = {
|
relationship_colors = {
|
||||||
's': 'blue',
|
'stable': 'blue',
|
||||||
'd': 'red'
|
'developing': 'red'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,16 +40,15 @@ def main():
|
||||||
graph.edge_attr['arrowsize'] = 0.5
|
graph.edge_attr['arrowsize'] = 0.5
|
||||||
|
|
||||||
# Add nodes to graph
|
# Add nodes to graph
|
||||||
for user in data:
|
for user in data['members']:
|
||||||
graph.add_node(user['name'], fillcolor=gender_colors[user['gender']])
|
graph.add_node(user['name'], fillcolor=gender_colors[user['gender']])
|
||||||
|
|
||||||
# Add edges to graph
|
# Add edges to graph
|
||||||
for user1 in data:
|
for (member1,member2,rel,fluid) in data['relationships']:
|
||||||
for (user2, rel, fluid) in user1['connections']:
|
graph.add_edge(member1, member2, style=fluid_colors[fluid], color=relationship_colors[rel])
|
||||||
graph.add_edge(user1['name'], user2, style=fluid_colors[fluid], color=relationship_colors[rel])
|
|
||||||
|
|
||||||
graph.layout()
|
graph.layout()
|
||||||
graph.draw('/tmp/graph.png')
|
graph.draw('poly_network.png')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__': main()
|
if __name__ == '__main__': main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user