78 public: |
78 public: |
79 |
79 |
80 SmartGraph() : nodes(), edges() { } |
80 SmartGraph() : nodes(), edges() { } |
81 SmartGraph(const SmartGraph &_g) : nodes(_g.nodes), edges(_g.edges) { } |
81 SmartGraph(const SmartGraph &_g) : nodes(_g.nodes), edges(_g.edges) { } |
82 |
82 |
83 int nodeNum() const { return nodes.size(); } //FIXME: What is this? |
83 ///Number of nodes. |
84 int edgeNum() const { return edges.size(); } //FIXME: What is this? |
84 int nodeNum() const { return nodes.size(); } |
85 |
85 ///Number of edges. |
86 ///\bug This function does something different than |
86 int edgeNum() const { return edges.size(); } |
87 ///its name would suggests... |
87 |
88 int maxNodeId() const { return nodes.size(); } //FIXME: What is this? |
88 /// Maximum node ID. |
89 ///\bug This function does something different than |
89 |
90 ///its name would suggests... |
90 /// Maximum node ID. |
91 int maxEdgeId() const { return edges.size(); } //FIXME: What is this? |
91 ///\sa id(Node) |
|
92 int maxNodeId() const { return nodes.size()-1; } |
|
93 /// Maximum edge ID. |
|
94 |
|
95 /// Maximum edge ID. |
|
96 ///\sa id(Edge) |
|
97 int maxEdgeId() const { return edges.size()-1; } |
92 |
98 |
93 Node tail(Edge e) const { return edges[e.n].tail; } |
99 Node tail(Edge e) const { return edges[e.n].tail; } |
94 Node head(Edge e) const { return edges[e.n].head; } |
100 Node head(Edge e) const { return edges[e.n].head; } |
95 |
101 |
96 NodeIt& first(NodeIt& v) const { |
102 NodeIt& first(NodeIt& v) const { |
100 OutEdgeIt& first(OutEdgeIt& e, const Node v) const { |
106 OutEdgeIt& first(OutEdgeIt& e, const Node v) const { |
101 e=OutEdgeIt(*this,v); return e; } |
107 e=OutEdgeIt(*this,v); return e; } |
102 InEdgeIt& first(InEdgeIt& e, const Node v) const { |
108 InEdgeIt& first(InEdgeIt& e, const Node v) const { |
103 e=InEdgeIt(*this,v); return e; } |
109 e=InEdgeIt(*this,v); return e; } |
104 |
110 |
|
111 /// Node ID. |
|
112 |
|
113 /// The ID of a valid Node is a nonnegative integer not greater than |
|
114 /// \ref maxNodeId(). The range of the ID's is not surely continuous |
|
115 /// and the greatest node ID can be actually less then \ref maxNodeId(). |
|
116 /// |
|
117 /// The ID of the \ref INVALID node is -1. |
|
118 ///\return The ID of the node \c v. |
105 static int id(Node v) { return v.n; } |
119 static int id(Node v) { return v.n; } |
|
120 /// Edge ID. |
|
121 |
|
122 /// The ID of a valid Edge is a nonnegative integer not greater than |
|
123 /// \ref maxEdgeId(). The range of the ID's is not surely continuous |
|
124 /// and the greatest edge ID can be actually less then \ref maxEdgeId(). |
|
125 /// |
|
126 /// The ID of the \ref INVALID edge is -1. |
|
127 ///\return The ID of the edge \c e. |
106 static int id(Edge e) { return e.n; } |
128 static int id(Edge e) { return e.n; } |
107 |
129 |
108 Node addNode() { |
130 Node addNode() { |
109 Node n; n.n=nodes.size(); |
131 Node n; n.n=nodes.size(); |
110 nodes.push_back(NodeT()); //FIXME: Hmmm... |
132 nodes.push_back(NodeT()); //FIXME: Hmmm... |