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

fixing bug for non-int node labels when plotting #133

Merged
merged 1 commit into from
Jul 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions xgi/drawing/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,13 @@ def barycenter_spring_layout(H, return_phantom_graph=False):
G.add_edge(i, j)

# Adding phantom nodes and connections therein
phantom_node_id = max(H.nodes) + 1
# I will start from the first int node-label available
try:
phantom_node_id = max([n for n in H.nodes if isinstance(n, int)]) + 1
except ValueError:
# The list of node-labels has no integers, so I start from 0
phantom_node_id = 0

# Looping over the hyperedges of different order (from triples up)
for d in range(2, max_edge_order(H) + 1):
# Hyperedges of order d (d=2: triplets, etc.)
Expand Down Expand Up @@ -219,7 +225,13 @@ def weighted_barycenter_spring_layout(H, return_phantom_graph=False):
G.add_edge(i, j, weight=d)

# Adding phantom nodes and connections therein
phantom_node_id = max(H.nodes) + 1
# I will start from the first int node-label available
try:
phantom_node_id = max([n for n in H.nodes if isinstance(n, int)]) + 1
except ValueError:
# The list of node-labels has no integers, so I start from 0
phantom_node_id = 0

# Looping over the hyperedges of different order (from triples up)
for d in range(2, max_edge_order(H) + 1):
# Hyperedges of order d (d=2: triplets, etc.)
Expand Down