MCPcopy Create free account
hub / github.com/OpenBMB/ToolBench / find_ancestor_intersection

Method find_ancestor_intersection

toolbench/inference/Tree/Tree.py:101–114  ·  view source on GitHub ↗

find the first common ancestor

(cls, node1, node2)

Source from the content-addressed store, hash-verified

99
100 @classmethod
101 def find_ancestor_intersection(cls, node1, node2):
102 '''
103 find the first common ancestor
104 '''
105 if node1 == None or node2 == None:
106 return None
107 if node1 == node2:
108 return node1
109 length1 = node1.get_depth()
110 length2 = node2.get_depth()
111 if length1 > length2:
112 return tree_node.find_ancestor_intersection(node1.father,node2)
113 else:
114 return tree_node.find_ancestor_intersection(node1, node2.father)
115
116
117

Callers 1

rank2_subfixFunction · 0.80

Calls 1

get_depthMethod · 0.80

Tested by

no test coverage detected