-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"fixed_nodes" argument of get_fruchterman_reingold_layout function isn't handled properly for multi-component graphs #30
Comments
OK, the problem isn't the size of the network, it is in the handling of multiple components: each has it's own bbox, and the specified positions may or may not fall inside of them:
I don't know how to work around that problem in an easy way, and not sure if my use-case is even within the intended scope of the library: I want to keep one of the nodes fixed in the center of the plot and let the other arrange themselves. I think I'll write my own algorithm for that |
Hi, thanks for raising the issue and sorry about the late reply -- I was on holiday.
That is a very good point. I hadn't considered that conflict. Off the top of my head, I also can't think of a clean solution. To handle fixed nodes in conjunction with multiple components one would have to first draw the components containing the fixed nodes and then pass the remaining white space to a rectangle packing algorithm. However, I don't know of any implementation that handles non-rectangular "packing areas".
Well, at the very least, netgraph should raise an exception, or at least a warning.
The FR algorithm with fixed nodes works pretty well for that. A shell layout can also look good. Assuming that the other components in your ego-graph are unconnected nodes, then you can simply arrange them on a circle around the connected part of the graph.
Otherwise, I would connect each unconnected component to my node of interest using an edge with low weight, and then use FR to determine the node positions. |
Hi, thanks for the answer
this sounds like a good solution for me! |
…ayout that occurs when explicit initial positions fall outside of canvas space allocated when handling multiple components (issue #30).
I haven't fixed the underlying issue but at least the problem is documented in the docstring and the error message indicates the potential issue (when it does indeed occur), so hopefully no other user is sent on an extended bug hunt. |
I was personnally also confronted to this issue and defaulted to networkx non-interactive graphs in this case. It happens sometime when some of my nodes are not connected (which is a degraded case in my case so this issue is not that problematic). |
python version: 3.8.10
netgraph version: 4.1.0
I'm trying to use the
get_fruchterman_reingold_layout
function to get node positions for plotting. When used on edges/nodes from a small graph, it fails, raisingValueError: Some given node positions are not within the data range specified by origin and scale!
and showing different scale values than the ones that were actually provided.Below is a minimal example: using the smaller list of edges results in error, while the second, bigger one, is fine.
The text was updated successfully, but these errors were encountered: