Commit c2c36cc9 authored by Sean Leavey's avatar Sean Leavey

Merge branch 'master' into feature/cli-shell

parents 808fdd5d 5a79ea31
......@@ -223,7 +223,7 @@ output_file_argument = click.argument("output_file", type=click.File("w"), defau
graph_layout_argument = click.option(
"--layout",
type=click.Choice(graph_layouts().keys()),
default="planar",
default="spring",
help="Graph layout algorithm to use.",
)
network_type_argument = click.option(
......@@ -503,7 +503,10 @@ def graph(ctx, input_file, network_type, layout, graphviz, legacy):
except ImportError as e:
state.print_error("Dependency not installed", e)
else:
model.plot_graph(layout=layout, network=network_type)
try:
model.plot_graph(layout=layout, network=network_type)
except Exception as e:
state.print_error(e)
@cli.command()
......
......@@ -1855,7 +1855,14 @@ class Model:
f"Layout '{layout}' is not available in NetworkX (choose from {choices})."
)
pos = posfunc(network)
try:
pos = posfunc(network)
except nx.NetworkXException as e:
if "G is not planar" in str(e):
raise Exception(
"Graph cannot be represented with a planar layout. Try a different layout."
) from e
nx.draw(network, pos, with_labels=True)
plt.show()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment