"the given point must have 2 dimensions" when modifying the center of a 3D layout? (Python)

Really confused on this. My application reads a file into a graph, and then I create a 3D layout for it, and then modifies the center. However when I load in one of my datasets I get this error: “the given point must have 2 dimensions” from the second line:

miscBucketLayout = graphList[0].layout("fr3d")

Totally lost on what could cause this, if anyone could help me out or give me a direction to start on it would be greatly appreciated.

Cross-posted to StackOverflow

I cannot reproduce this. Can you provide a complete minimal example?

I am not sure how I could do this, graphList[0] is just a normal Graph object, but on its own it doesn’t create this error…

There are many guides on the internet with helpful tips on creating minimal reproducible examples. I linked to one above and here’s another: How to create a Minimal, Reproducible Example - Help Center - Stack Overflow

We would only be able to help if we are able to reproduce the problem on our end.

I managed to reproduce this. This happens if your graph is empty. In igraph, the layout is simply a list of lists, wrapped in a Layout object, and the dimensionality of the layout is given by the first element of the list. If the list is empty, the Layout object falls back to assuming that it’s a 2D layout.

An easy workaround is to do this:

miscBucketLayout._dim = 3

or this:

miscBucketLayout = Layout(graphList[0].layout("fr3d"), dim=3)
1 Like