Package flumotion :: Package common :: Module dag :: Class DAG
[show private | hide private]
[frames | no frames]

Class DAG

Loggable --+
           |
          DAG


I represent a Directed Acyclic Graph.

You can add objects to me as Nodes and then express dependency by adding edges.
Method Summary
  __init__(self)
  addEdge(self, parent, child, parenttype, childtype)
I add an edge between two nodes in the DAG.
  addNode(self, object, type)
I add a node to the DAG.
list of object getAllNodesByType(self, type)
I return all the objects with node type specified by type
list of objects getAncestors(self, object, objtype, *types)
I return a list of objects that are ancestors of this object,objtype.
list of (object,Integer) getAncestorsTyped(self, object, objtype, *types)
I return a list of (object, type) tuples that are ancestors of this object,objtype.
list of objects getChildren(self, object, objtype, types)
I return a list of objects that are direct children of this object,objtype.
list of (object, object) getChildrenTyped(self, object, objtype, types)
I return a list of (object, type) tuples that are direct children of this object,objtype.
list of objects getOffspring(self, object, objtype, *types)
I return a list of objects that are offspring of this object,objtype.
list of (object,Integer) getOffspringTyped(self, object, objtype, *types)
I return a list of (object, type) tuples that are offspring of this object,objtype.
list of (object, object) getParents(self, object, objtype, types)
I return a list of objects that are direct parents of this object, objtype.
list of (object, object) getParentsTyped(self, object, objtype, types)
I return a list of (object, type) tuples that are direct parents of this object, objtype.
  hasCycle(self)
I return whether or not the graph has a cycle.
Boolean hasNode(self, object, type)
I check if a node exists in the DAG.
Boolean isFloating(self, object, objtype)
I return whether the object is floating: no parents and no children.
  removeEdge(self, parent, child, parenttype, childtype)
I remove an edge between two nodes in the DAG.
  removeNode(self, object, type)
I remove a node that exists in the DAG.
list of (object, type) sort(self)
I return a topologically sorted list of objects.
  _assertExists(self, object, type)
  _dfs(self, node)
  _getNode(self, object, type)
list of {Node} _sortPreferred(self, list, clearState)
I return a topologically sorted list of nodes, using list as a preferred order for the algorithm.
    Inherited from Loggable
  debug(self, *args)
Log a debug message.
dict doLog(self, level, where, format, *args, **kwargs)
Log a message at the given level, with the possibility of going higher up in the stack.
  error(self, *args)
Log an error.
  info(self, *args)
Log an informational message.
  log(self, *args)
Log a log message.
  logFunction(self, *args)
Overridable log function.
  logObjectName(self)
Overridable object name function.
  warning(self, *args)
Log a warning.
  warningFailure(self, failure, swallow)
Log a warning about a Failure.

Class Variable Summary
    Inherited from Loggable
Implements __implemented__ = <implementedBy flumotion.common.log.Lo...
ClassProvides __providedBy__ = <zope.interface.declarations.ClassProvi...
ClassProvides __provides__ = <zope.interface.declarations.ClassProvide...
str logCategory: Implementors can provide a category to log their messages under.

Method Details

addEdge(self, parent, child, parenttype=0, childtype=0)

I add an edge between two nodes in the DAG.
Parameters:
parent - The object that is to be the parent.
child - The object that is to be the child.
parenttype - The type of the parent object (optional).
childtype - The type of the child object (optional).

addNode(self, object, type=0)

I add a node to the DAG.
Parameters:
object - object to put in the DAG
type - optional type for the object

getAllNodesByType(self, type)

I return all the objects with node type specified by type
Returns:
list of object

getAncestors(self, object, objtype=0, *types)

I return a list of objects that are ancestors of this object,objtype.
Parameters:
object - object to return ancestors of.
objtype - type of object (optional).
           (type=Integer)
types - types of ancestors that you want returned.
Returns:
list of objects

getAncestorsTyped(self, object, objtype=0, *types)

I return a list of (object, type) tuples that are ancestors of this object,objtype.
Parameters:
object - object to return ancestors of.
objtype - type of object (optional).
           (type=Integer)
types - types of ancestors that you want ancestors of.
Returns:
list of (object,Integer)

getChildren(self, object, objtype=0, types=None)

I return a list of objects that are direct children of this object,objtype.
Parameters:
object - object to return children of.
objtype - type of object (optional).
           (type=Integer)
types - a list of types of children that you want. None means all.
           (type=list of Integers)
Returns:
list of objects

getChildrenTyped(self, object, objtype=0, types=None)

I return a list of (object, type) tuples that are direct children of this object,objtype.
Parameters:
object - object to return children of
objtype - type of object (optional)
types - a list of types of children that you want. None means all.
           (type=list)
Returns:
list of (object, object)

getOffspring(self, object, objtype=0, *types)

I return a list of objects that are offspring of this object,objtype.
Parameters:
object - object to return children of.
objtype - type of object (optional).
           (type=Integer)
types - types of children that you want offspring returned of.
Returns:
list of objects

getOffspringTyped(self, object, objtype=0, *types)

I return a list of (object, type) tuples that are offspring of this object,objtype.
Parameters:
object - object to return children of.
objtype - type of object (optional).
           (type=Integer)
types - a list of types of children that you want. None means all.
           (type=list of Integers)
Returns:
list of (object,Integer)

getParents(self, object, objtype=0, types=None)

I return a list of objects that are direct parents of this object, objtype.
Parameters:
object - object to return parents of.
objtype - type of object (optional)
types - List of types of parents that you want. None means all.
           (type=list)
Returns:
list of (object, object)

getParentsTyped(self, object, objtype=0, types=None)

I return a list of (object, type) tuples that are direct parents of this object, objtype.
Parameters:
object - object to return parents of
objtype - type of object (optional)
types - A list of types of parents that you want. None means all.
           (type=list or None)
Returns:
list of (object, object)

hasCycle(self)

I return whether or not the graph has a cycle.

If it has, some operations on it will fail and raise CycleError.

hasNode(self, object, type=0)

I check if a node exists in the DAG.
Parameters:
object - The object to check existence of.
type - An optional type for the object to check.
           (type=Integer)
Returns:
Boolean

isFloating(self, object, objtype=0)

I return whether the object is floating: no parents and no children.
Parameters:
object - object to check if floating.
objtype - type of object (optional).
           (type=Integer)
Returns:
Boolean

removeEdge(self, parent, child, parenttype=0, childtype=0)

I remove an edge between two nodes in the DAG.
Parameters:
parent - The object that is the parent,
child - The object that is the child.
parenttype - The type of the parent object (optional).
childtype - The type of the child object (optional).

removeNode(self, object, type=0)

I remove a node that exists in the DAG. I also remove any edges pointing to this node.
Parameters:
object - The object to remove.
type - The type of object to remove (optional).

sort(self)

I return a topologically sorted list of objects.
Returns:
list of (object, type)

_sortPreferred(self, list=None, clearState=True)

I return a topologically sorted list of nodes, using list as a preferred order for the algorithm.
Parameters:
list - a list of (object, type) tuples in preference order
           (type=list of (object, type))
Returns:
list of {Node}

Generated by Epydoc 2.1 on Sun Oct 26 16:39:17 2008 http://epydoc.sf.net