Skip to content

Commit

Permalink
Fix bug (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwlandry authored Aug 29, 2022
1 parent 75d6f9c commit a5d9c70
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions xgi/classes/hypergraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,19 +811,20 @@ def remove_node_from_edge(self, edge, node):
removed.
"""
self._edge[edge].remove(node)
self._node[node].remove(edge)
if len(self._edge[edge]) == 0:
del self._edge[edge]
del self._edge_attr[edge]

try:
self._node[node].remove(edge)
except KeyError as e:
raise XGIError(f"Node {node} not in the hypergraph") from e
except ValueError as e:
raise XGIError(f"Node {node} not in edge {edge}") from e

try:
self._edge[edge].remove(node)
except KeyError as e:
raise XGIError(f"Edge {edge} not in the hypergraph") from e
except ValueError as e:
raise XGIError(f"Edge {edge} does not contain node {node}") from e

if not self._edge[edge]:
del self._edge[edge]
del self._edge_attr[edge]
Expand Down

0 comments on commit a5d9c70

Please sign in to comment.