123 \endcode |
123 \endcode |
124 |
124 |
125 \code |
125 \code |
126 std::cout << "Edges:"; |
126 std::cout << "Edges:"; |
127 for (EdgeIt i(g); i!=INVALID; ++i) |
127 for (EdgeIt i(g); i!=INVALID; ++i) |
128 std::cout << " (" << g.id(g.tail(i)) << "," << g.id(g.head(i)) << ")"; |
128 std::cout << " (" << g.id(g.source(i)) << "," << g.id(g.target(i)) << ")"; |
129 std::cout << std::endl; |
129 std::cout << std::endl; |
130 \endcode |
130 \endcode |
131 |
131 |
132 \code |
132 \code |
133 Edges: (0,2) (1,2) (0,1) (2,1) (1,0) (2,0) |
133 Edges: (0,2) (1,2) (0,1) (2,1) (1,0) (2,0) |
134 \endcode |
134 \endcode |
135 |
135 |
136 We can also iterate through all edges of the graph very similarly. The head and |
136 We can also iterate through all edges of the graph very similarly. The target and |
137 tail member functions can be used to access the endpoints of an edge. |
137 source member functions can be used to access the endpoints of an edge. |
138 |
138 |
139 \code |
139 \code |
140 NodeIt first_node(g); |
140 NodeIt first_node(g); |
141 |
141 |
142 std::cout << "Out-edges of node " << g.id(first_node) << ":"; |
142 std::cout << "Out-edges of node " << g.id(first_node) << ":"; |
143 for (OutEdgeIt i(g, first_node); i!=INVALID; ++i) |
143 for (OutEdgeIt i(g, first_node); i!=INVALID; ++i) |
144 std::cout << " (" << g.id(g.tail(i)) << "," << g.id(g.head(i)) << ")"; |
144 std::cout << " (" << g.id(g.source(i)) << "," << g.id(g.target(i)) << ")"; |
145 std::cout << std::endl; |
145 std::cout << std::endl; |
146 |
146 |
147 std::cout << "In-edges of node " << g.id(first_node) << ":"; |
147 std::cout << "In-edges of node " << g.id(first_node) << ":"; |
148 for (InEdgeIt i(g, first_node); i!=INVALID; ++i) |
148 for (InEdgeIt i(g, first_node); i!=INVALID; ++i) |
149 std::cout << " (" << g.id(g.tail(i)) << "," << g.id(g.head(i)) << ")"; |
149 std::cout << " (" << g.id(g.source(i)) << "," << g.id(g.target(i)) << ")"; |
150 std::cout << std::endl; |
150 std::cout << std::endl; |
151 \endcode |
151 \endcode |
152 |
152 |
153 \code |
153 \code |
154 Out-edges of node 2: (2,0) (2,1) |
154 Out-edges of node 2: (2,0) (2,1) |
164 for (EdgeIt e(g); e!=INVALID; ++e) |
164 for (EdgeIt e(g); e!=INVALID; ++e) |
165 m.set(e, 10 - g.id(e)); |
165 m.set(e, 10 - g.id(e)); |
166 |
166 |
167 std::cout << "Id Edge Value" << std::endl; |
167 std::cout << "Id Edge Value" << std::endl; |
168 for (EdgeIt e(g); e!=INVALID; ++e) |
168 for (EdgeIt e(g); e!=INVALID; ++e) |
169 std::cout << g.id(e) << " (" << g.id(g.tail(e)) << "," << g.id(g.head(e)) |
169 std::cout << g.id(e) << " (" << g.id(g.source(e)) << "," << g.id(g.target(e)) |
170 << ") " << m[e] << std::endl; |
170 << ") " << m[e] << std::endl; |
171 \endcode |
171 \endcode |
172 |
172 |
173 \code |
173 \code |
174 Id Edge Value |
174 Id Edge Value |