Changeset 679
- Timestamp:
- 08/27/17 19:48:02 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mds-and-trees/tree-genealogy.py
r678 r679 359 359 def calculate_measures(self): 360 360 print("Calculating measures...") 361 self.compute_depth() 361 362 self.compute_adepth() 362 self.compute_depth()363 363 self.compute_children() 364 364 self.compute_kind() … … 534 534 self.props["adepth"] = [0 for x in range(len(self.tree.children))] 535 535 536 def compute_local_adepth(node): 537 my_adepth = 0 538 for c in self.tree.children[node]: 539 my_adepth = max(my_adepth, compute_local_adepth(c)+1) 540 self.props["adepth"][node] = my_adepth 541 return my_adepth 542 543 compute_local_adepth(0) 536 # order by maximum depth of the parent guarantees that co child is evaluated before its parent 537 visiting_order = [i for i in range(0, len(self.tree.parents))] 538 visiting_order = sorted(visiting_order, key=lambda q: 539 0 if q == 0 else max([self.props["depth"][d] for d in self.tree.parents[q]]))[::-1] 540 541 for node in visiting_order: 542 children = self.tree.children[node] 543 if len(children) != 0: 544 # 0 by default 545 self.props["adepth"][node] = max([self.props["adepth"][child] for child in children])+1 544 546 self.normalize_prop('adepth') 545 547
Note: See TracChangeset
for help on using the changeset viewer.