COPASI API  4.16.103
CDependencyGraph.h
Go to the documentation of this file.
2 // \$Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/utilities/CDependencyGraph.h,v \$
3 // \$Revision: 1.21 \$
4 // \$Name: \$
5 // \$Author: shoops \$
6 // \$Date: 2011/03/07 19:34:55 \$
8
9 // Copyright (C) 2011 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
13
14 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc. and EML Research, gGmbH.
17
18 #ifndef COPASI_CDependencyGraph
19 #define COPASI_CDependencyGraph
20
21 #include <iostream>
22 #include <vector>
23 #include <set>
24
25 /**
26  * CDependencyGraphNode describes a node in the dependency graph.
27  */
29 {
30 public:
31  /**
32  * Constructor
33  */
35
36  /**
37  * The destructor
38  */
40
41  /**
42  * Add a dependent to the given node, represented by its node number.
43  * This then represents an edge in the graph.
44  * @param const size_t \$ node_num The dependency, the node to which the edge connects.
45  */
46  void addDependent(const size_t & node_num);
47
48  /**
49  * Return a vector of the dependents.
50  * @return const std::set <size_t> & A vector of the dependents.
51  */
52
53  const std::set <size_t> & getDependents() const;
54
55  /**
56  * insert operator
57  */
58  friend std::ostream & operator<<(std::ostream &os,
59  const CDependencyGraphNode & d);
60
61 private:
62  /**
63  * A vector containing the edges for this node. An edge is
64  * specified by the remote node to which it connects.
65  */
66
67  std::set <size_t> mDependents;
68 };
69
70 /**
71  * CDependencyGraph describes a dependency graph.
72  */
73
75 {
76 public:
77  /**
78  * Constructor
79  */
81
82  /**
83  * Desctructor
84  */
86
87  void resize(const size_t & n);
88
89  /**
90  * Add a dependent for a particular node.
91  * @param node The number of the node.
92  * @param dependent The number of the dependent node.
93  */
94  void addDependent(const size_t & node, const size_t & dependent);
95
96  /**
97  * Retrieve a vector of dependents for a given node.
98  * @param node The number of the node to access.
99  * @return A vector of node numbers.
100  */
101  const std::set <size_t> &getDependents(const size_t & node) const;
102
103  void clear();
104
105 private:
106
107  /**
108  * Add a node with a given number.
109  * @param node The number of the node to add.
110  */
111  void addNode(const size_t & node);
112
113  /**
114  * A vector containing the nodes in the graph
115  */
116  std::vector<CDependencyGraphNode> mNodes;
117
118  /**
119  * insert operator
120  */
121  friend std::ostream & operator<<(std::ostream &os,
122  const CDependencyGraph & d);
123 };
124
125 #endif // COPASI_CDependencyGraph