Tree Concept.

class core.graph.interface.treeconcept.EditableTreeConcept[source]

Bases: core.graph.interface.treeconcept.MutableTreeConcept

add_child_tree(parent, tree)[source]

Add a tree after the children of the parent vertex. Complexity have to be O(1) if tree == sub_tree()

Parameters:
  • parent -- vertex identifier
  • tree -- a rooted tree
insert_sibling_tree(vid, tree)[source]

Insert a tree before the vid. vid and the root of the tree are siblings. Complexity have to be O(1) if tree comes from the actual tree ( tree= sef.sub_tree() )

Parameters:
  • vid -- vertex identifier
  • tree -- a rooted tree
sub_tree(vtx_id)[source]

Return a reference of the tree rooted on vtx_id in O(1).

Returns:Editable Tree
class core.graph.interface.treeconcept.MutableTreeConcept[source]

Bases: core.graph.interface.treeconcept.RootedTreeConcept, core.graph.interface.graphconcept.MutableVertexGraphConcept

A mutable rooted tree. The substitute method is defined outside the interface. substitute(self,vid,tree)

add_child(parent, child)[source]

Add a child at the end of children

Parameters:
  • parent -- The parent identifier.
  • child -- The child identifier.
insert_parent(vtx_id, parent_id)[source]

Insert parent_id between vtx_id and its actual parent.

Parameters:
  • vtx_id -- a vertex identifier
  • parent_id -- a vertex identifier
insert_sibling(vid1, vid2)[source]

Insert vid2 before vid1.

Parameters:
  • vid1 -- a vertex identifier
  • vid2 -- the vertex to insert
class core.graph.interface.treeconcept.OrderedTreeConcept[source]

Bases: core.graph.interface.treeconcept.RootedTreeConcept

An ordered tree is a rooted tree where an order relation is defined between chidren.

first_child(vid)[source]

Return the first child of vid

Parameters:vid -- The vertex identifier.
Returns:vid
last_child(vid)[source]

Return the last child of vid

Parameters:vid -- The vertex identifier.
Returns:vid
next_sibling(vid)[source]

Return next sibling

Parameters:vid -- The vertex identifier.
Returns:vid
previous_sibling(vid)[source]

Return previous sibling

Parameters:vid -- The vertex identifier.
Returns:vid
class core.graph.interface.treeconcept.RootedTreeConcept[source]

Bases: core.graph.interface.graphconcept.VertexListGraphConcept

Rooted Tree interface.

depth(vid), depth() and sub_tree(vid) can be extenal algorithms.

children(vtx_id)[source]

Return a vertex iterator

Parameters:vtx_id -- The vertex identifier.
Returns:iter of vertex identifier
get_root()[source]

Return the tree root.

Returns:vertex identifier
is_leaf(vtx_id)[source]

Test if vtx_id is a leaf.

Returns:bool
nb_children(vtx_id)[source]

Return the number of children

Parameters:vtx_id -- The vertex identifier.
Return type:int
nb_siblings(vtx_id)[source]

Return the number of siblings

Returns:int
parent(vtx_id)[source]

Return the parent of vtx_id.

Parameters:vtx_id -- The vertex identifier.
Returns:vertex identifier
set_root(vtx_id)[source]

Set the tree root.

Parameters:vtx_id -- The vertex identifier.
siblings(vtx_id)[source]

Return an iterator of vtx_id siblings. vtx_id is not include in siblings.

Parameters:vtx_id -- The vertex identifier.
Returns:iter of vertex identifier
root

Return the tree root.

Returns:vertex identifier
class core.graph.interface.treeconcept.Visitor[source]

Bases: object

Used during a tree traversal.

post_order(vtx_id)[source]

todo

pre_order(vtx_id)[source]

todo

core.graph.interface.treeconcept.traverse_tree(tree, vtx_id, visitor)[source]

Traverse a tree in a prefix or postfix way.

We call a visitor for each vertex. This is usefull for printing, cmputing or storing vertices in a specific order.

See boost.graph.

Previous topic

<no title>

Next topic

<no title>

This Page