Skip to content

[Bug]: Handle visualization of empty graph properly #553

Description

@thierry-martinez

Currently, visualizing an empty graph (or an empty pattern) raises an exception.

>>> OpenGraph(nx.Graph(), (), (), {}).draw()
[...]
  File "/home/tmartine/miniforge3/lib/python3.13/site-packages/graphix/visualization.py", line 710, in _
    l_max = max(layers.values())
ValueError: max() iterable argument is empty

>>> Pattern().draw()
[...]
  File "/home/tmartine/miniforge3/lib/python3.13/site-packages/numpy/linalg/_linalg.py", line 144, in _raise_linalgerror_singular
    raise LinAlgError("Singular matrix")
numpy.linalg.LinAlgError: Singular matrix

In #549, the situation will be handled more gracefully by raising a ValueError with a dedicated message. However, it would be preferable to allow visualization of empty graphs without any failures.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions