Skip to content

Commit

Permalink
Delete least common ancestor finding function (since this function is…
Browse files Browse the repository at this point in the history
… not used within the algorithm).
hoanganhngo610 committed Sep 14, 2023
1 parent 851b710 commit 14a09af
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions river/cluster/hcluster.py
Original file line number Diff line number Diff line change
@@ -297,28 +297,6 @@ def find_path(root, path, k):
path.pop()
return False

def lca(self, i, j):
# Find the least common ancestor
# Adapted from https://www.geeksforgeeks.org/lowest-common-ancestor-binary-tree-set-1/

if self.root is None:
return -1

path_i = []
path_j = []

if not HierarchicalClustering.find_path(
self.root, path_i, i
) or not HierarchicalClustering.find_path(self.root, path_j, j):
return -1

k = 0
while k < len(path_i) and k < len(path_j):
if path_i[k] != path_j[k]:
break
k += 1
return path_i[k - 1]

def leaves(self, v):
# find all the leaves from node v

0 comments on commit 14a09af

Please sign in to comment.