Skip to content

Commit

Permalink
Removed check on visited on function to calculate depth
Browse files Browse the repository at this point in the history
Multiple paths can lead to the same node and this must be processed mutliple times
  • Loading branch information
valearna committed Jan 3, 2024
1 parent ec693a7 commit f05998c
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions genedescriptions/ontology_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,9 @@ def set_all_depths_in_subgraph(ontology: Ontology, root_id: str, relations: List
the root. max calculates the length of the longest path, min the one of the shortest
current_depth (int): the current depth in the ontology
"""
visited = set()
stack = [(root_id, current_depth)]
while stack:
node_id, current_depth = stack.pop()
if node_id in visited:
continue
visited.add(node_id)
if "depth" not in ontology.node(node_id):
ontology.node(node_id)["depth"] = current_depth
else:
Expand Down

0 comments on commit f05998c

Please sign in to comment.