Skip to content

Commit

Permalink
fixing bug for non-int node labels when plotting (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
iaciac authored Jul 6, 2022
1 parent 63cb831 commit 512eb97
Showing 1 changed file with 14 additions and 2 deletions.
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

0 comments on commit 512eb97

Please sign in to comment.