Package visgraph :: Module pathcore
[hide private]
[frames] | no frames]

Module pathcore

source code

Paths are enumerated threads through a particular graph. They are implemented as an optimized hierarchical graph using python primitives to save memory and processing time...

Each "leaf" node may be tracked back for it's entire path by tracking back to parents.

Functions [hide private]
 
newPathNode(parent=None, **kwargs)
Create a new path node with the given properties
source code
 
getNodeParent(pnode) source code
 
delPathNode(pnode)
Prune (remove) this node from the parent...
source code
 
getNodeIndex(pnode) source code
 
getNodeKids(pnode)
Return the list of children nodes for the specified node.
source code
 
getRootNode(pnode)
Get the root node for the path tree which contains pnode.
source code
 
getLeafNodes(pnode)
Get all the leaf nodes for the path tree which contains the pnode.
source code
 
getPathToNode(pnode)
Return a list of the path nodes which lead from the root node to the specified path node.
source code
 
getAllPaths(pnode)
Get a list of lists which has each path flattened out.
source code
 
getNodeProp(pnode, key, default=None)
Get a property from the given node, returning default in the case that the specified property is not present.
source code
 
getPathProp(pnode, key, default=None)
Retrieve the specified property by walking the give path backward until the property is found.
source code
 
setNodeProp(pnode, key, value)
Set a spcified property on the given path node.
source code
 
isPathLoop(pnode, key, value)
Assuming you have some identifier property (such as graph node id) being set on the path nodes, you may use this API to determine if the current path has a node with the specified key/value property.
source code
 
getPathLoopCount(pnode, key, value)
Assuming that the key is unique, walk the current path and see how many times "key" has the specified value.
source code
Function Details [hide private]

getNodeKids(pnode)

source code 

Return the list of children nodes for the specified node.

Example: for knode in getNodeKids(pnode):

getRootNode(pnode)

source code 

Get the root node for the path tree which contains pnode.

Example: root = getRootNode(branchnode)

getLeafNodes(pnode)

source code 

Get all the leaf nodes for the path tree which contains the pnode.

Example: for leaf in getLeafNodes(root):

getAllPaths(pnode)

source code 

Get a list of lists which has each path flattened out.

Example: for path in getAllPaths(pnode):
             print 'Found A Path:'
             for node in path:
                doStuff()

getNodeProp(pnode, key, default=None)

source code 

Get a property from the given node, returning
default in the case that the specified property is
not present.

Example:
    name = getNodeProp(pnode, 'name', 'Unknown')

getPathProp(pnode, key, default=None)

source code 

Retrieve the specified property by walking the give
path backward until the property is found.  Returns
the specified default if the specified key is not found
as a property of any node in the given path.

Example:
    name = getPathProp(pnode, 'name', 'Unknown')

setNodeProp(pnode, key, value)

source code 

Set a spcified property on the given path node.

Example:
    setNodeProp(pnode, 'name', 'woot')

isPathLoop(pnode, key, value)

source code 

Assuming you have some identifier property (such as graph node id)
being set on the path nodes, you may use this API to determine if
the current path has a node with the specified key/value property.

Example:
    if searchPathLoop(pnode, 'nid', 5):
        continue

getPathLoopCount(pnode, key, value)

source code 

Assuming that the key is unique, walk the current path and see how many times "key" has the specified value. This will be how many instances of a loop have been encountered.