Skip to content
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

Can I adjust how close hyperedges can be drawn in proximity to nodes? #85

Closed
galenseilis opened this issue Feb 17, 2022 · 1 comment
Closed

Comments

@galenseilis
Copy link

I made the following diagram using Hypernetworkx's draw command.

image

The node fst_score node appears really close to the 233 hyperedge, making it hard to distinguish whether the node is a member of the hyperedge. Is there a setting an argument somewhere that would allow me to ensure that the hyperedges maintain a minimal distance from the nodes?

@madelynshapiro
Copy link
Collaborator

Thank you for raising this issue; for general information on draw, please refer to the documentation and Tutorial 2 - Visualization Methods.

There are several methods for customizing the layout of a hypergraph when using draw. From the documentation:

The default layout algorithm is nx.spring_layout, but other layouts can be passed in. The Hypergraph is converted to a bipartite graph, and the layout algorithm is passed the bipartite graph.
If you have a pre-determined layout, you can pass in a pos dictionary. This is a dictionary mapping from node id’s to x-y coordinates. For example:

pos = {
'A': (0, 0),
'B': (1, 2),
'C': (5, -3)
}

will position the nodes {A, B, C} manually at the locations specified. The coordinate system is in Matplotlib “data coordinates”, and the figure will be centered within the figure.

For small layout adjustments on simple hypergraphs like the one in your example, I recommend doing something like this:

# get the positions for the default layout
pos = hnx.draw(H, return_pos=True)

# for the sake of this example, assume that the original position of the fst_score node is (1,1)
# we want to move it up and to the right, so increase the value of both coordinates
pos['fst_score'] = (2,2)

# redraw the hypergraph using the updated custom layout
hnx.draw(H, pos=pos)

You may need to play around a bit with the updated custom coordinates to achieve your desired layout. Feel free to follow up with specifics/code for your example if you'd like additional support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants