Skip to content

Commit

Permalink
Allow to draw without edge labels
Browse files Browse the repository at this point in the history
  • Loading branch information
thvitt committed Aug 10, 2018
1 parent 7f5106d commit f6a3c2c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion visualize.py
Expand Up @@ -61,7 +61,7 @@ def _load_style(filename):
return yaml.load(f)


def write_dot(graph: nx.MultiDiGraph, target='base_graph.dot', style=_load_style('styles.yaml'), highlight=None, record='auto'):
def write_dot(graph: nx.MultiDiGraph, target='base_graph.dot', style=_load_style('styles.yaml'), highlight=None, record='auto', edge_labels=True):
logger.info('Writing %s ...', target)
target_path = Path(target)
target_path.parent.mkdir(exist_ok=True, parents=True)
Expand Down Expand Up @@ -107,6 +107,11 @@ def write_dot(graph: nx.MultiDiGraph, target='base_graph.dot', style=_load_style
if kind in style['node']:
simplified.nodes[node].update(style['node'][kind])

if not edge_labels:
for u, v, k, attr in simplified.edges(data=True, keys=True):
if 'label' in attr:
del attr['label']

agraph: AGraph = nx.nx_agraph.to_agraph(simplified)
agraph.edge_attr['fontname'] = 'Ubuntu derivative Faust'
agraph.edge_attr['fontsize'] = 8
Expand Down

0 comments on commit f6a3c2c

Please sign in to comment.