caesar0301 / treelib

An efficient implementation of tree data structure in python 2/3.
http://treelib.readthedocs.io/en/latest/
Other
801 stars 185 forks source link

rsearch how to select path with minimal distance between each node #175

Open giamas opened 3 years ago

giamas commented 3 years ago

I'm currently using Treelib to generate a tree with node in which, for each fo them, is stored distance from its own parent node. How can be possible to use rsearch to find path back to root with minimal distances between every node and its paretn?

Each node has a payload data element of this class:

class Star: def init(self, position, p, hz, adv, civ, dead, life): self.x, self.y = position self.size = 1 self.thickness = 1 self.n_planets = p self.n_planets_HZ = hz self.n_planets_adv = adv self.n_planets_civ = civ self.n_planets_dead = dead self.n_planets_life = life self.spectre = '' self.colour = (100, 100, 100) self.mass = 0 self.radius = 0 self.luminosity = 0 self.position = position self.parent_distance = 0

When I generate the Tree from a random field f single point (star) I stored in each of them distance between child and parent. Now, I want to come back to root using the path composed by step with minimal distance between node and related parents. How can be done?

Thanks,