igraph / python-igraph

Python interface for igraph
GNU General Public License v2.0
1.31k stars 249 forks source link

Bug: No such attribute for layout_bipartite #772

Closed tanlin2013 closed 6 months ago

tanlin2013 commented 6 months ago

Describe the bug When calling g.layout_bipartite(), I got the error

InternalError: Error at src/_igraph/attributes.c:1700: No such attribute. -- Invalid value

I have tried to reinstall the package, but it doesn't help.

To reproduce

ig.draw(g, layout=g.layout_bipartite())

Version information

szhorvat commented 6 months ago

This is not a bug, but the behaviour does seem confusing. See the docs:

https://python.igraph.org/en/stable/api/igraph.GraphBase.html#layout_bipartite

The partitions are taken from the "types" attribute by default, which is not present here. You need to provide the partitions.

You can do this:

(bipartite, types) = g.is_bipartite(return_types=True)
g.layout_bipartite(types)
szhorvat commented 6 months ago

@ntamas It might be nice to make that error message a bit better and state which attribute was not found. But perhaps we don't have the resources now, and should focus on the new interface. It'd be nice the have a more convenient default behaviour in the new interface, such as: take types if that attribute exists, but otherwise automatically compute bipartite partitions (and fail if the graph is not bipartite). In the Mathematica interface I automatically compute partitions by default, and allow specifying them manually otherwise.

tanlin2013 commented 6 months ago

I see, thanks for answering! It works now.

I agree this is a bit confusing. Perhaps a temporary fix would be to write a few more words on the documentation?

You may keep this post or close it now.

szhorvat commented 6 months ago

I submitted PR #773 to try to improve error messages a little bit.

ntamas commented 6 months ago

773 is now merged, thanks for the contribution!