Tree

Represents a simple tree.

Created on 6 Mar 2014

@author: paulross

class cpip.util.Tree.DuplexAdjacencyList

Represents a set of parent/child relationships (and their inverse) as Adjacency Lists.

allChildren

Returns an unordered list of objects that have at least one parent.

allParents

Returns an unordered list of objects that have at least one child.

children(parent)

Returns all immediate children of a given parent.

hasChild(child)

Returns True if the given child has any parents.

hasParent(parent)

Returns True if the given parent has any children.

parents(child)

Returns all immediate parents of a given child.

treeChildParent(theObj)

Returns a Tree() object where the links are the relationships between child and parent. Cycles are not reproduced i.e. if a -> b and b -> c and c-> a then treeChildParent(‘a’) returns [‘a’, ‘c’, ‘b’,] treeChildParent(‘b’) returns [‘b’, ‘a’, ‘c’,] treeChildParent(‘c’) returns [‘c’, ‘b’, ‘a’,]

treeParentChild(theObj)

Returns a Tree() object where the links are the relationships between parent and child. Cycles are not reproduced i.e. if a -> b and b -> c and c-> a then treeParentChild(‘a’) returns [‘a’, ‘b’, ‘c’,] treeParentChild(‘b’) returns [‘b’, ‘c’, ‘a’,] treeParentChild(‘c’) returns [‘c’, ‘a’, ‘c’,]

class cpip.util.Tree.Tree(obj)

Represents a simple tree of objects.

branches()

Returns all the possible branches through the tree as a list of lists of self._obj.

youngestChild

The latest child to be added, may raise IndexError if no children.

Previous topic

StrTree

Next topic

XmlWrite

This Page