Skip to content

Commit 0e125af

Browse files
committed
More complete colours attribute, simple and complex options.
1 parent a739d0b commit 0e125af

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

gitnet/log.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ def generate_nodes(self, mode1, mode2, keep_atom1=[], keep_vector1=[], keep_atom
723723
node_tuple_list.append((n,nodes[n]))
724724
return node_tuple_list
725725

726-
def generate_network(self, mode1, mode2, edge_helper=net_edges_simple, edge_attributes=[], mode1_atom_attrs=[],
726+
def generate_network(self, mode1, mode2, colours=None, edge_helper=net_edges_simple, edge_attributes=[], mode1_atom_attrs=[],
727727
mode2_atom_attrs=[], mode1_vector_attrs=[], mode2_vector_attrs=[]):
728728
"""
729729
An abstract network generator. For networks that contain authors, any authors that made
@@ -796,19 +796,29 @@ def generate_network(self, mode1, mode2, edge_helper=net_edges_simple, edge_attr
796796
edges = self.generate_edges(mode1, mode2, helper=edge_helper, edge_attributes=edge_attributes)
797797
for edge in edges:
798798
graph.add_edges_from([(edge[0], edge[1], edge[2])])
799-
for n in graph.nodes():
800-
if graph.node[n]['type'] == 'author':
801-
graph.node[n]['colour'] = 'oldlace'
802-
elif ".py" in graph.node[n]['id']:
803-
graph.node[n]['colour'] = 'springgreen'
804-
elif ".cc" in graph.node[n]['id']:
805-
graph.node[n]['colour'] = 'seagreen'
806-
elif ".sh" in graph.node[n]['id']:
807-
graph.node[n]["colour"] = "slateblue"
808-
elif ".html" in graph.node[n]["id"]:
809-
graph.node[n]["colour"] = "plum"
810-
else:
811-
graph.node[n]['colour'] = 'lightgrey'
799+
if colours != None:
800+
if colours == 'simple':
801+
for n in graph.nodes():
802+
if graph.node[n]['type'] == mode1:
803+
graph.node[n]['colour'] = 'oldlace'
804+
if graph.node[n]['type'] == mode2:
805+
graph.node[n]['colour'] = 'lightcoral'
806+
elif colours == 'complex':
807+
for n in graph.nodes():
808+
if graph.node[n]['type'] == 'author':
809+
graph.node[n]['colour'] = 'oldlace'
810+
elif ".py" in graph.node[n]['id']:
811+
graph.node[n]['colour'] = 'springgreen'
812+
elif ".cc" in graph.node[n]['id']:
813+
graph.node[n]['colour'] = 'seagreen'
814+
elif ".md" in graph.node[n]['id']:
815+
graph.node[n]['colour'] = 'orange'
816+
elif ".sh" in graph.node[n]['id']:
817+
graph.node[n]["colour"] = "slateblue"
818+
elif ".html" in graph.node[n]["id"]:
819+
graph.node[n]["colour"] = "plum"
820+
else:
821+
graph.node[n]['colour'] = 'lightgrey'
812822
return graph
813823

814824
def write_edges(self, fname, mode1, mode2, helper=net_edges_simple, edge_attribute=['weight', 'date']):

0 commit comments

Comments
 (0)