148 typedef typename Graph::template EdgeMap<int> IntEdgeMap; \ |
148 typedef typename Graph::template EdgeMap<int> IntEdgeMap; \ |
149 typedef typename Graph::template EdgeMap<double> DoubleEdgeMap |
149 typedef typename Graph::template EdgeMap<double> DoubleEdgeMap |
150 |
150 |
151 ///Create convenience typedefs for the bipartite graph types and iterators |
151 ///Create convenience typedefs for the bipartite graph types and iterators |
152 |
152 |
153 ///This \c \#define creates the same convenient type definitions as defined |
153 ///This \c \#define creates the same convenient type definitions as |
154 ///by \ref GRAPH_TYPEDEFS(BpGraph) and ten more, namely it creates |
154 ///defined by \ref GRAPH_TYPEDEFS(BpGraph) and ten more, namely it |
155 ///\c RedNode, \c RedIt, \c BoolRedMap, \c IntRedMap, \c DoubleRedMap, |
155 ///creates \c RedNode, \c RedNodeIt, \c BoolRedNodeMap, |
156 ///\c BlueNode, \c BlueIt, \c BoolBlueMap, \c IntBlueMap, \c DoubleBlueMap. |
156 ///\c IntRedNodeMap, \c DoubleRedNodeMap, \c BlueNode, \c BlueNodeIt, |
|
157 ///\c BoolBlueNodeMap, \c IntBlueNodeMap, \c DoubleBlueNodeMap. |
157 /// |
158 /// |
158 ///\note If the graph type is a dependent type, ie. the graph type depend |
159 ///\note If the graph type is a dependent type, ie. the graph type depend |
159 ///on a template parameter, then use \c TEMPLATE_BPGRAPH_TYPEDEFS() |
160 ///on a template parameter, then use \c TEMPLATE_BPGRAPH_TYPEDEFS() |
160 ///macro. |
161 ///macro. |
161 #define BPGRAPH_TYPEDEFS(BpGraph) \ |
162 #define BPGRAPH_TYPEDEFS(BpGraph) \ |
162 GRAPH_TYPEDEFS(BpGraph); \ |
163 GRAPH_TYPEDEFS(BpGraph); \ |
163 typedef BpGraph::RedNode RedNode; \ |
164 typedef BpGraph::RedNode RedNode; \ |
164 typedef BpGraph::RedIt RedIt; \ |
165 typedef BpGraph::RedNodeIt RedNodeIt; \ |
165 typedef BpGraph::RedMap<bool> BoolRedMap; \ |
166 typedef BpGraph::RedNodeMap<bool> BoolRedNodeMap; \ |
166 typedef BpGraph::RedMap<int> IntRedMap; \ |
167 typedef BpGraph::RedNodeMap<int> IntRedNodeMap; \ |
167 typedef BpGraph::RedMap<double> DoubleRedMap; \ |
168 typedef BpGraph::RedNodeMap<double> DoubleRedNodeMap; \ |
168 typedef BpGraph::BlueNode BlueNode; \ |
169 typedef BpGraph::BlueNode BlueNode; \ |
169 typedef BpGraph::BlueIt BlueIt; \ |
170 typedef BpGraph::BlueNodeIt BlueNodeIt; \ |
170 typedef BpGraph::BlueMap<bool> BoolBlueMap; \ |
171 typedef BpGraph::BlueNodeMap<bool> BoolBlueNodeMap; \ |
171 typedef BpGraph::BlueMap<int> IntBlueMap; \ |
172 typedef BpGraph::BlueNodeMap<int> IntBlueNodeMap; \ |
172 typedef BpGraph::BlueMap<double> DoubleBlueMap |
173 typedef BpGraph::BlueNodeMap<double> DoubleBlueNodeMap |
173 |
174 |
174 ///Create convenience typedefs for the bipartite graph types and iterators |
175 ///Create convenience typedefs for the bipartite graph types and iterators |
175 |
176 |
176 ///\see BPGRAPH_TYPEDEFS |
177 ///\see BPGRAPH_TYPEDEFS |
177 /// |
178 /// |
178 ///\note Use this macro, if the graph type is a dependent type, |
179 ///\note Use this macro, if the graph type is a dependent type, |
179 ///ie. the graph type depend on a template parameter. |
180 ///ie. the graph type depend on a template parameter. |
180 #define TEMPLATE_BPGRAPH_TYPEDEFS(BpGraph) \ |
181 #define TEMPLATE_BPGRAPH_TYPEDEFS(BpGraph) \ |
181 TEMPLATE_GRAPH_TYPEDEFS(BpGraph); \ |
182 TEMPLATE_GRAPH_TYPEDEFS(BpGraph); \ |
182 typedef typename BpGraph::RedNode RedNode; \ |
183 typedef typename BpGraph::RedNode RedNode; \ |
183 typedef typename BpGraph::RedIt RedIt; \ |
184 typedef typename BpGraph::RedNodeIt RedNodeIt; \ |
184 typedef typename BpGraph::template RedMap<bool> BoolRedMap; \ |
185 typedef typename BpGraph::template RedNodeMap<bool> BoolRedNodeMap; \ |
185 typedef typename BpGraph::template RedMap<int> IntRedMap; \ |
186 typedef typename BpGraph::template RedNodeMap<int> IntRedNodeMap; \ |
186 typedef typename BpGraph::template RedMap<double> DoubleRedMap; \ |
187 typedef typename BpGraph::template RedNodeMap<double> DoubleRedNodeMap; \ |
187 typedef typename BpGraph::BlueNode BlueNode; \ |
188 typedef typename BpGraph::BlueNode BlueNode; \ |
188 typedef typename BpGraph::BlueIt BlueIt; \ |
189 typedef typename BpGraph::BlueNodeIt BlueNodeIt; \ |
189 typedef typename BpGraph::template BlueMap<bool> BoolBlueMap; \ |
190 typedef typename BpGraph::template BlueNodeMap<bool> BoolBlueNodeMap; \ |
190 typedef typename BpGraph::template BlueMap<int> IntBlueMap; \ |
191 typedef typename BpGraph::template BlueNodeMap<int> IntBlueNodeMap; \ |
191 typedef typename BpGraph::template BlueMap<double> DoubleBlueMap |
192 typedef typename BpGraph::template BlueNodeMap<double> DoubleBlueNodeMap |
192 |
193 |
193 /// \brief Function to count the items in a graph. |
194 /// \brief Function to count the items in a graph. |
194 /// |
195 /// |
195 /// This function counts the items (nodes, arcs etc.) in a graph. |
196 /// This function counts the items (nodes, arcs etc.) in a graph. |
196 /// The complexity of the function is linear because |
197 /// The complexity of the function is linear because |
563 static void copy(const From& from, BpGraph &to, |
564 static void copy(const From& from, BpGraph &to, |
564 RedNodeRefMap& redNodeRefMap, |
565 RedNodeRefMap& redNodeRefMap, |
565 BlueNodeRefMap& blueNodeRefMap, |
566 BlueNodeRefMap& blueNodeRefMap, |
566 EdgeRefMap& edgeRefMap) { |
567 EdgeRefMap& edgeRefMap) { |
567 to.clear(); |
568 to.clear(); |
568 for (typename From::RedIt it(from); it != INVALID; ++it) { |
569 for (typename From::RedNodeIt it(from); it != INVALID; ++it) { |
569 redNodeRefMap[it] = to.addRedNode(); |
570 redNodeRefMap[it] = to.addRedNode(); |
570 } |
571 } |
571 for (typename From::BlueIt it(from); it != INVALID; ++it) { |
572 for (typename From::BlueNodeIt it(from); it != INVALID; ++it) { |
572 blueNodeRefMap[it] = to.addBlueNode(); |
573 blueNodeRefMap[it] = to.addBlueNode(); |
573 } |
574 } |
574 for (typename From::EdgeIt it(from); it != INVALID; ++it) { |
575 for (typename From::EdgeIt it(from); it != INVALID; ++it) { |
575 edgeRefMap[it] = to.addEdge(redNodeRefMap[from.redNode(it)], |
576 edgeRefMap[it] = to.addEdge(redNodeRefMap[from.redNode(it)], |
576 blueNodeRefMap[from.blueNode(it)]); |
577 blueNodeRefMap[from.blueNode(it)]); |
1162 /// OrigBpGraph::NodeMap<NewBpGraph::Node> nr(orig_graph); |
1163 /// OrigBpGraph::NodeMap<NewBpGraph::Node> nr(orig_graph); |
1163 /// cg.nodeRef(nr); |
1164 /// cg.nodeRef(nr); |
1164 /// // Create cross references (inverse) for the edges |
1165 /// // Create cross references (inverse) for the edges |
1165 /// NewBpGraph::EdgeMap<OrigBpGraph::Edge> ecr(new_graph); |
1166 /// NewBpGraph::EdgeMap<OrigBpGraph::Edge> ecr(new_graph); |
1166 /// cg.edgeCrossRef(ecr); |
1167 /// cg.edgeCrossRef(ecr); |
1167 /// // Copy a red map |
1168 /// // Copy a red node map |
1168 /// OrigBpGraph::RedMap<double> ormap(orig_graph); |
1169 /// OrigBpGraph::RedNodeMap<double> ormap(orig_graph); |
1169 /// NewBpGraph::RedMap<double> nrmap(new_graph); |
1170 /// NewBpGraph::RedNodeMap<double> nrmap(new_graph); |
1170 /// cg.edgeMap(ormap, nrmap); |
1171 /// cg.redNodeMap(ormap, nrmap); |
1171 /// // Copy a node |
1172 /// // Copy a node |
1172 /// OrigBpGraph::Node on; |
1173 /// OrigBpGraph::Node on; |
1173 /// NewBpGraph::Node nn; |
1174 /// NewBpGraph::Node nn; |
1174 /// cg.node(on, nn); |
1175 /// cg.node(on, nn); |
1175 /// // Execute copying |
1176 /// // Execute copying |
1192 typedef typename To::RedNode TRedNode; |
1193 typedef typename To::RedNode TRedNode; |
1193 typedef typename To::BlueNode TBlueNode; |
1194 typedef typename To::BlueNode TBlueNode; |
1194 typedef typename To::Arc TArc; |
1195 typedef typename To::Arc TArc; |
1195 typedef typename To::Edge TEdge; |
1196 typedef typename To::Edge TEdge; |
1196 |
1197 |
1197 typedef typename From::template RedMap<TRedNode> RedNodeRefMap; |
1198 typedef typename From::template RedNodeMap<TRedNode> RedNodeRefMap; |
1198 typedef typename From::template BlueMap<TBlueNode> BlueNodeRefMap; |
1199 typedef typename From::template BlueNodeMap<TBlueNode> BlueNodeRefMap; |
1199 typedef typename From::template EdgeMap<TEdge> EdgeRefMap; |
1200 typedef typename From::template EdgeMap<TEdge> EdgeRefMap; |
1200 |
1201 |
1201 struct NodeRefMap { |
1202 struct NodeRefMap { |
1202 NodeRefMap(const From& from, const RedNodeRefMap& red_node_ref, |
1203 NodeRefMap(const From& from, const RedNodeRefMap& red_node_ref, |
1203 const BlueNodeRefMap& blue_node_ref) |
1204 const BlueNodeRefMap& blue_node_ref) |
1350 /// The key type of the new map \c tmap should be the Node type of |
1351 /// The key type of the new map \c tmap should be the Node type of |
1351 /// the destination graph with the red items, and the key type of |
1352 /// the destination graph with the red items, and the key type of |
1352 /// the original map \c map should be the Node type of the source |
1353 /// the original map \c map should be the Node type of the source |
1353 /// graph. |
1354 /// graph. |
1354 template <typename FromMap, typename ToMap> |
1355 template <typename FromMap, typename ToMap> |
1355 BpGraphCopy& redMap(const FromMap& map, ToMap& tmap) { |
1356 BpGraphCopy& redNodeMap(const FromMap& map, ToMap& tmap) { |
1356 _red_maps.push_back(new _core_bits::MapCopy<From, RedNode, |
1357 _red_maps.push_back(new _core_bits::MapCopy<From, RedNode, |
1357 RedNodeRefMap, FromMap, ToMap>(map, tmap)); |
1358 RedNodeRefMap, FromMap, ToMap>(map, tmap)); |
1358 return *this; |
1359 return *this; |
1359 } |
1360 } |
1360 |
1361 |
1401 /// The key type of the new map \c tmap should be the Node type of |
1402 /// The key type of the new map \c tmap should be the Node type of |
1402 /// the destination graph with the blue items, and the key type of |
1403 /// the destination graph with the blue items, and the key type of |
1403 /// the original map \c map should be the Node type of the source |
1404 /// the original map \c map should be the Node type of the source |
1404 /// graph. |
1405 /// graph. |
1405 template <typename FromMap, typename ToMap> |
1406 template <typename FromMap, typename ToMap> |
1406 BpGraphCopy& blueMap(const FromMap& map, ToMap& tmap) { |
1407 BpGraphCopy& blueNodeMap(const FromMap& map, ToMap& tmap) { |
1407 _blue_maps.push_back(new _core_bits::MapCopy<From, BlueNode, |
1408 _blue_maps.push_back(new _core_bits::MapCopy<From, BlueNode, |
1408 BlueNodeRefMap, FromMap, ToMap>(map, tmap)); |
1409 BlueNodeRefMap, FromMap, ToMap>(map, tmap)); |
1409 return *this; |
1410 return *this; |
1410 } |
1411 } |
1411 |
1412 |