Biorithm  1.1
Public Member Functions | Protected Member Functions | Protected Attributes
DAG< NodeType > Class Template Reference

#include <dag.h>

List of all members.

Public Member Functions

 DAG ()
 DAG (const DAG< NodeType > &rhs)
 DAG (istream *in)
virtual ~DAG ()
const DAG< NodeType > & operator= (const DAG &rhs)
void clear ()
virtual void addNode (NodeType *node)
void computeDifference (DAG< NodeType > &other, DAG< NodeType > &difference)
virtual void computePower (unsigned int exponent, DAG< NodeType > &powerDAG)
virtual void computeLeaves (vector< NodeType * > &leaves, unsigned int type=0)
virtual void computeRoots (vector< NodeType * > &roots, unsigned int type=0)
virtual void computeTopologicalSort (vector< NodeType * > &sortedFunctions, unsigned int type=0)
virtual void computeTransitiveClosure (DAG< NodeType > &closedDAG)
virtual void computeTransitiveReduction (DAG< NodeType > &reducedDAG)
unsigned int getNumEdges () const
unsigned int getNumNodes () const
void print (string file) const
void print (ostream &ostr) const
 DAG ()
 DAG (const DAG< NodeType > &rhs)
 DAG (istream *in)
virtual ~DAG ()
const DAG< NodeType > & operator= (const DAG &rhs)
void clear ()
virtual void addNode (NodeType *node)
void computeDifference (DAG< NodeType > &other, DAG< NodeType > &difference)
virtual void computePower (unsigned int exponent, DAG< NodeType > &powerDAG)
virtual void computeLeaves (vector< NodeType * > &leaves, unsigned int type=0)
virtual void computeRoots (vector< NodeType * > &roots, unsigned int type=0)
virtual void computeTopologicalSort (vector< NodeType * > &sortedFunctions, unsigned int type=0)
virtual void computeTransitiveClosure (DAG< NodeType > &closedDAG)
virtual void computeTransitiveReduction (DAG< NodeType > &reducedDAG)
unsigned int getNumEdges () const
unsigned int getNumNodes () const
void print (string file) const
void print (ostream &ostr) const

Protected Member Functions

void _copy (const DAG< NodeType > &rhs)
void _copyNodes (const DAG< NodeType > &rhs)
unsigned int _getNodeIndex (const NodeType *node) const
void _copy (const DAG< NodeType > &rhs)
void _copyNodes (const DAG< NodeType > &rhs)
unsigned int _getNodeIndex (const NodeType *node) const

Protected Attributes

vector< NodeType * > _nodes
map< const NodeType
*, unsigned int > 
_nodesToIndices

Detailed Description

template<typename NodeType>
class DAG< NodeType >

A class that encapsulates a Directed Acyclic Graph. NodeType is a class that stores information for a particular node. In a particular instantiation of DAG, NodeType should be a subclass of DAGNode.


Constructor & Destructor Documentation

template<typename NodeType>
DAG< NodeType >::DAG ( ) [inline]

Constructor

template<typename NodeType>
DAG< NodeType >::DAG ( const DAG< NodeType > &  rhs) [inline]

Copy constructor

template<typename NodeType>
DAG< NodeType >::DAG ( istream *  in)

Constructor

Parameters:
*inA stream pointer (eg: &cout, &infile, &myStringStream)
template<typename NodeType>
virtual DAG< NodeType >::~DAG ( ) [inline, virtual]

Destructor

template<typename NodeType>
DAG< NodeType >::DAG ( ) [inline]

Constructor

template<typename NodeType>
DAG< NodeType >::DAG ( const DAG< NodeType > &  rhs) [inline]

Copy constructor

template<typename NodeType>
DAG< NodeType >::DAG ( istream *  in)

Constructor

Parameters:
*inA stream pointer (eg: &cout, &infile, &myStringStream)
template<typename NodeType>
virtual DAG< NodeType >::~DAG ( ) [inline, virtual]

Destructor


Member Function Documentation

template<typename NodeType>
virtual void DAG< NodeType >::addNode ( NodeType *  node) [inline, virtual]

Adds a node to the DAG.

Note:
The DAG does not manage the storage of the added nodes. The calling method is responsible for allocating and deallocating storage. The DAG simply stores the pointers to the nodes in the DAG.
template<typename NodeType>
virtual void DAG< NodeType >::addNode ( NodeType *  node) [inline, virtual]

Adds a node to the DAG.

Note:
The DAG does not manage the storage of the added nodes. The calling method is responsible for allocating and deallocating storage. The DAG simply stores the pointers to the nodes in the DAG.
template<typename NodeType>
void DAG< NodeType >::clear ( ) [inline]

Clears memory used by the DAG.

template<typename NodeType>
void DAG< NodeType >::clear ( ) [inline]

Clears memory used by the DAG.

template<typename NodeType>
void DAG< NodeType >::computeDifference ( DAG< NodeType > &  other,
DAG< NodeType > &  difference 
)

Adds a node to the DAG.

Note:
The DAG does not manage the storage of the added nodes. The calling method is responsible for allocating and deallocating storage. The DAG simply stores the pointers to the nodes in the DAG. Computes the difference between the invocant and other.
Parameters:
[in]other,aninstance of DAG< NodeType >
[out]difference,aninstance of DAG< NodeType > that will hold the difference between the invocant and other.

The method adds those parent-child relations to difference that are in the invocant but not in other.

Warning:
The method requires that the invocant and other have exactly the same set of nodes and that the nodes be added to both DAGs in precisely the same order. You can meet this requirement if you constructed the invocant by assigning other to it or by invoking the copy constructor on other or vice-versa. This onerous requirement may go away in the future.
template<typename NodeType>
void DAG< NodeType >::computeDifference ( DAG< NodeType > &  other,
DAG< NodeType > &  difference 
)

Adds a node to the DAG.

Note:
The DAG does not manage the storage of the added nodes. The calling method is responsible for allocating and deallocating storage. The DAG simply stores the pointers to the nodes in the DAG. Computes the difference between the invocant and other.
Parameters:
[in]other,aninstance of DAG< NodeType >
[out]difference,aninstance of DAG< NodeType > that will hold the difference between the invocant and other.

The method adds those parent-child relations to difference that are in the invocant but not in other.

Warning:
The method requires that the invocant and other have exactly the same set of nodes and that the nodes be added to both DAGs in precisely the same order. You can meet this requirement if you constructed the invocant by assigning other to it or by invoking the copy constructor on other or vice-versa. This onerous requirement may go away in the future.
template<typename NodeType>
void DAG< NodeType >::computeLeaves ( vector< NodeType * > &  leaves,
unsigned int  type = 0 
) [virtual]

Compute the leaves of the DAG, i.e., nodes without any children.

template<typename NodeType>
virtual void DAG< NodeType >::computeLeaves ( vector< NodeType * > &  leaves,
unsigned int  type = 0 
) [virtual]

Compute the leaves of the DAG, i.e., nodes without any children.

template<typename NodeType>
void DAG< NodeType >::computePower ( unsigned int  exponent,
DAG< NodeType > &  powerDAG 
) [virtual]

Computes the kth power of the DAG.

Parameters:
[in]exponent,thevalue of the power to compute.
[out]powerDAG,aninstance of DAG< NodeType > that will contain the power.

The kth power of a DAG is another DAG that contains an edge between nodes a and b if the there is a path of length k between the nodes in the original DAG. For example, the first power of a DAG is the DAG itself and the second power of a DAG connects each node to all its grandparents in the original DAG. The union of all powers of a DAG is the transitive closure of the DAG.

template<typename NodeType>
virtual void DAG< NodeType >::computePower ( unsigned int  exponent,
DAG< NodeType > &  powerDAG 
) [virtual]

Computes the kth power of the DAG.

Parameters:
[in]exponent,thevalue of the power to compute.
[out]powerDAG,aninstance of DAG< NodeType > that will contain the power.

The kth power of a DAG is another DAG that contains an edge between nodes a and b if the there is a path of length k between the nodes in the original DAG. For example, the first power of a DAG is the DAG itself and the second power of a DAG connects each node to all its grandparents in the original DAG. The union of all powers of a DAG is the transitive closure of the DAG.

template<typename NodeType>
void DAG< NodeType >::computeRoots ( vector< NodeType * > &  roots,
unsigned int  type = 0 
) [virtual]

Compute the roots of the DAG, i.e., nodes without any parents.

template<typename NodeType>
virtual void DAG< NodeType >::computeRoots ( vector< NodeType * > &  roots,
unsigned int  type = 0 
) [virtual]

Compute the roots of the DAG, i.e., nodes without any parents.

template<typename NodeType>
void DAG< NodeType >::computeTopologicalSort ( vector< NodeType * > &  sortedFunctions,
unsigned int  type = 0 
) [virtual]

Performs a topological sort of the functions in the DAG from the root downward.

The nodes in each connected component of the DAG appear consecutively in the sorted order.

Parameters:
sortedFunction,areference to a vector of pointers to instance of NodeType. The method fills this vector with the sorted list of functions.
type,aninteger defining what type of relations to use when performing the topological sort.
template<typename NodeType>
virtual void DAG< NodeType >::computeTopologicalSort ( vector< NodeType * > &  sortedFunctions,
unsigned int  type = 0 
) [virtual]

Performs a topological sort of the functions in the DAG from the root downward.

The nodes in each connected component of the DAG appear consecutively in the sorted order.

Parameters:
sortedFunction,areference to a vector of pointers to instance of NodeType. The method fills this vector with the sorted list of functions.
type,aninteger defining what type of relations to use when performing the topological sort.
template<typename NodeType>
void DAG< NodeType >::computeTransitiveClosure ( DAG< NodeType > &  closedDAG) [virtual]

Compute the transitive closure of the DAG.

Parameters:
[out]closedDAG,thecomputed transitive closure.

For every pair of nodes a and b in the invocant such that b is an ancestor of a, the methods adds b as a parent of a in the transitive closure.

template<typename NodeType>
virtual void DAG< NodeType >::computeTransitiveClosure ( DAG< NodeType > &  closedDAG) [virtual]

Compute the transitive closure of the DAG.

Parameters:
[out]closedDAG,thecomputed transitive closure.

For every pair of nodes a and b in the invocant such that b is an ancestor of a, the methods adds b as a parent of a in the transitive closure.

template<typename NodeType>
void DAG< NodeType >::computeTransitiveReduction ( DAG< NodeType > &  reducedDAG) [virtual]

Compute the transitive reduction of the DAG.

Parameters:
[out]reducedDAG,thecomputed transitive reduction.

For every pair of nodes a and b in the invocant such that b is a parent of a, the methods ensures that b is an ancestor of a in the transitive reduction. The method includes all edges in the invocant in the reduction that are not edges in the square of the invocant.

Note:
The method works correctly if and only if the invocant is transitively closed.
template<typename NodeType>
virtual void DAG< NodeType >::computeTransitiveReduction ( DAG< NodeType > &  reducedDAG) [virtual]

Compute the transitive reduction of the DAG.

Parameters:
[out]reducedDAG,thecomputed transitive reduction.

For every pair of nodes a and b in the invocant such that b is a parent of a, the methods ensures that b is an ancestor of a in the transitive reduction. The method includes all edges in the invocant in the reduction that are not edges in the square of the invocant.

Note:
The method works correctly if and only if the invocant is transitively closed.
template<typename NodeType >
unsigned int DAG< NodeType >::getNumEdges ( ) const

Reads information about the Gene Ontology.

Parameters:
fileA string containing the location of a file. Reads information about the DAG.
*inA stream pointer (eg: &cout, &infile, &myStringStream) Performs a transitive closure traversal of the DAG to determine the ancestors of each node.

Partial traversals are cached making this a constant time operation when repeated and fast if some of the ancestors have already been computed

Parameters:
objA gene ontology function object pointer
typean integer defining what type of traversal will be done:
  • 0 means any parent relation (currently is_a and part_of)
  • 1 means follow only is_a relations
  • 2 means follow only part_of relations
Returns:
A set of ancestors of the type specified

Returns a node's direct parents

Parameters:
objA pointer to an instance of NodeType.
typean integer defining what type of parents to return:
  • 0 means any parent relation (currently is_a and part_of)
  • 1 means only is_a relations
  • 2 means only part_of relations
Returns:
A set of parents of the type specified

Performs a transitive closure traversal of the DAG to determine the descendants of each function.

Partial traversals are cached making this a constant time operation when repeated and fast if some of the descendants have already been computed.

Parameters:
objA pointer to an instance of NodeType.
typean integer defining what type of traversal will be done:
  • 0 means any descendant relation (currently is_a and part_of)
  • 1 means follow only is_a relations
  • 2 means follow only part_of relations
Returns:
A set of descendants of the type specified

Returns a node's direct children

Parameters:
objA pointer to an instance of NodeType.
typean integer defining what type of children to return:
  • 0 means any child relation (currently is_a and part_of)
  • 1 means only is_a relations
  • 2 means only part_of relations
Returns:
A set of children of the type specified

Constant time lookup of function by id (or alternative id)

Parameters:
idThe id to lookup
Returns:
a go function pointer that has that id Constant time lookup of function by id (or alternative id)
Parameters:
idThe id to lookup. This id is a string.
Returns:
a go function pointer that has that id.

The method converts id to an integer to removing any prefix of the form "GO:" Return the number of edges (parent-child relationships) in the DAG.

template<typename NodeType>
unsigned int DAG< NodeType >::getNumEdges ( ) const

Reads information about the Gene Ontology.

Parameters:
fileA string containing the location of a file. Reads information about the DAG.
*inA stream pointer (eg: &cout, &infile, &myStringStream) Performs a transitive closure traversal of the DAG to determine the ancestors of each node.

Partial traversals are cached making this a constant time operation when repeated and fast if some of the ancestors have already been computed

Parameters:
objA gene ontology function object pointer
typean integer defining what type of traversal will be done:
  • 0 means any parent relation (currently is_a and part_of)
  • 1 means follow only is_a relations
  • 2 means follow only part_of relations
Returns:
A set of ancestors of the type specified

Returns a node's direct parents

Parameters:
objA pointer to an instance of NodeType.
typean integer defining what type of parents to return:
  • 0 means any parent relation (currently is_a and part_of)
  • 1 means only is_a relations
  • 2 means only part_of relations
Returns:
A set of parents of the type specified

Performs a transitive closure traversal of the DAG to determine the descendants of each function.

Partial traversals are cached making this a constant time operation when repeated and fast if some of the descendants have already been computed.

Parameters:
objA pointer to an instance of NodeType.
typean integer defining what type of traversal will be done:
  • 0 means any descendant relation (currently is_a and part_of)
  • 1 means follow only is_a relations
  • 2 means follow only part_of relations
Returns:
A set of descendants of the type specified

Returns a node's direct children

Parameters:
objA pointer to an instance of NodeType.
typean integer defining what type of children to return:
  • 0 means any child relation (currently is_a and part_of)
  • 1 means only is_a relations
  • 2 means only part_of relations
Returns:
A set of children of the type specified

Constant time lookup of function by id (or alternative id)

Parameters:
idThe id to lookup
Returns:
a go function pointer that has that id Constant time lookup of function by id (or alternative id)
Parameters:
idThe id to lookup. This id is a string.
Returns:
a go function pointer that has that id.

The method converts id to an integer to removing any prefix of the form "GO:" Return the number of edges (parent-child relationships) in the DAG.

template<typename NodeType>
unsigned int DAG< NodeType >::getNumNodes ( ) const

Return the number of nodes in the DAG.

template<typename NodeType >
unsigned int DAG< NodeType >::getNumNodes ( ) const

Return the number of nodes in the DAG.

template<typename NodeType>
const DAG< NodeType >& DAG< NodeType >::operator= ( const DAG< NodeType > &  rhs) [inline]

Assignment operator

template<typename NodeType>
const DAG< NodeType >& DAG< NodeType >::operator= ( const DAG< NodeType > &  rhs) [inline]

Assignment operator

template<typename NodeType >
void DAG< NodeType >::print ( string  file) const

Print the edges of the DAG to the output file.

The method outputs the edges of the DAG in tab-delimited form. Each line contains the id of a child node and the id of a parent node separated by a tab.

template<typename NodeType>
void DAG< NodeType >::print ( string  file) const

Print the edges of the DAG to the output file.

The method outputs the edges of the DAG in tab-delimited form. Each line contains the id of a child node and the id of a parent node separated by a tab.

template<typename NodeType >
void DAG< NodeType >::print ( ostream &  ostr) const

Print the edges of the DAG to the output stream.

The method outputs the edges of the DAG in tab-delimited form. Each line contains the id of a child node and the id of a parent node separated by a tab.

template<typename NodeType>
void DAG< NodeType >::print ( ostream &  ostr) const

Print the edges of the DAG to the output stream.

The method outputs the edges of the DAG in tab-delimited form. Each line contains the id of a child node and the id of a parent node separated by a tab.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Typedefs Friends