Common algorithms

Implementation of a set of algorithms for the MTG datastructure

openalea.mtg.algo.alg_height(g, v1, v2=None)[source]
openalea.mtg.algo.alg_order(g, v1, v2=None)[source]
openalea.mtg.algo.alg_rank(g, v1, v2=None)[source]
openalea.mtg.algo.ancestors(g, vid, **kwds)[source]

Return the vertices from vid to the root.

Parameters:
  • g: a tree or an MTG

  • vid: a vertex id which belongs to g

Returns:

an iterator from vid to the root of the tree.

openalea.mtg.algo.axis(g, vtx_id, scale=-1, **kwds)[source]

TODO: see aml doc

openalea.mtg.algo.descendants(g, vtx_id, scale=-1, **kwds)[source]

TODO: see aml doc

openalea.mtg.algo.edge_type(g, v)[source]
openalea.mtg.algo.extremities(g, vid, **kwds)[source]

TODO see aml doc Implement the method more efficiently…

openalea.mtg.algo.father(g, vid, scale=-1, **kwds)[source]

See aml.Father function.

openalea.mtg.algo.full_ancestors(g, v1, **kwds)[source]

Return the vertices from v1 to the root.

openalea.mtg.algo.height(g, v1, v2=None)[source]
openalea.mtg.algo.heights(g, scale=-1)[source]

Compute the order of all vertices at scale scale.

If scale == -1, the compute the order for vertices at the finer scale.

openalea.mtg.algo.local_axis(g, vtx_id, scale=-1, **kwds)[source]

Return a sequence of vertices connected by ‘<’ edges. The first element of the sequence is vtx_id.

openalea.mtg.algo.location(g, vid, **kwds)[source]

TODO: see doc aml.Location.

openalea.mtg.algo.lookForCommonAncestor(g, commonAncestors, currentNode)[source]
openalea.mtg.algo.lowestCommonAncestor(g, nodes)[source]

LCA algorithm

openalea.mtg.algo.order(g, v1, v2=None)[source]
openalea.mtg.algo.orders(g, scale=-1)[source]

Compute the order of all vertices at scale scale.

If scale == -1, the compute the order for vertices at the finer scale.

openalea.mtg.algo.path(g, vid1, vid2=None)[source]

Compute the vertices between v1 and v2. If v2 is None, return the path between v1 and the root. Otherelse, return the path between v1 and v2. If the graph is oriented from v1 to v2, sign is positive. Else, sign is negative.

openalea.mtg.algo.predecessor(g, vid, **kwds)[source]
openalea.mtg.algo.rank(g, v1, v2=None)[source]
openalea.mtg.algo.root(g, vid, RestrictedTo='NoRestriction', ContainedIn=None)[source]

TODO: see aml.Root doc string.

openalea.mtg.algo.sons(g, vid, **kwds)[source]

TODO: see doc aml.sons.

openalea.mtg.algo.split(g, scale=1)[source]

Split at scale.

openalea.mtg.algo.successor(g, vid, **kwds)[source]

TODO: see aml.Successor doc string.

openalea.mtg.algo.topological_path(g, v1, v2=None, edge=None)[source]
openalea.mtg.algo.trunk(g, vtx_id, scale=-1, **kwds)[source]
openalea.mtg.algo.union(g1, g2, vid1=None, vid2=None, edge_type='<')[source]

Return the union of the MTGs g1 and g2.

Parameters:
  • g1, g2 (MTG) : An MTG graph

  • vid1 : the anchor vertex identid=fier that belong to g1

  • vid2 : the root of the sub_mtg that belong to g2 which will be added to g1.

  • edge_type (str) : the type of the edge which will connect vid1 to vid2

openalea.mtg.algo.vertex_at_scale(g, vtx_id, scale)[source]

Download the source file ../../src/mtg/algo.py.