Skip to content

Commit

Permalink
fixup! Optional topologically sorted graph.
Browse files Browse the repository at this point in the history
  • Loading branch information
thvitt committed Jul 19, 2020
1 parent f20b7e1 commit c2b4c07
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/macrogen/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,10 @@ def order_graph(self, graph: nx.MultiDiGraph) -> nx.MultiDiGraph:

for u, v in windowed(ref_order, 2):
if result.has_edge(u, v, 0):
result[u][v][0]['weight'] = 1
result[u][v][0]['weight'] = 100
else:
result.add_edge(u, v, penwidth=0, dir='none', weight=1)
result.add_edge(u, v, penwidth=0, dir='none', weight=100)
result[u][v][0]['topo'] = True
return result


Expand Down
2 changes: 2 additions & 0 deletions src/macrogen/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ def write_dot(graph: nx.MultiDiGraph, target: Union[PathLike, str] = 'base_graph
for styled_attr in attr.keys() & style['edge']:
if attr[styled_attr]:
simplified.edges[u, v, k].update(style['edge'][styled_attr])
if 'topo' in attr and 'constraint' in attr:
del attr['constraint']

if 'node' in style:
for node, attr in simplified.nodes(data=True):
Expand Down

0 comments on commit c2b4c07

Please sign in to comment.