365 |
367 |
366 typedef std::vector<std::pair<std::string, Edge> > EdgeWriters; |
368 typedef std::vector<std::pair<std::string, Edge> > EdgeWriters; |
367 EdgeWriters edge_writers; |
369 EdgeWriters edge_writers; |
368 |
370 |
369 std::ostream& os; |
371 std::ostream& os; |
370 Graph& graph; |
372 const Graph& graph; |
371 |
373 |
372 }; |
374 }; |
373 |
375 |
|
376 /// Ready to use writer function. |
|
377 template<typename Graph, typename CapacityMap, typename CostMap> |
|
378 void writeGraph(std::ostream& os, const Graph &g, |
|
379 const CapacityMap& capacity, const typename Graph::Node &s, |
|
380 const typename Graph::Node &t, const CostMap& cost) { |
|
381 GraphWriter<Graph> reader(os, g); |
|
382 IdMap<Graph, typename Graph::Node> nodeIdMap(g); |
|
383 reader.addNodeMap("id", nodeIdMap); |
|
384 IdMap<Graph, typename Graph::Edge> edgeIdMap(g); |
|
385 reader.addEdgeMap("id", edgeIdMap); |
|
386 reader.addEdgeMap("capacity", capacity); |
|
387 reader.addEdgeMap("cost", cost); |
|
388 reader.addNode("source", s); |
|
389 reader.addNode("target", t); |
|
390 reader.run(); |
|
391 } |
|
392 |
|
393 /// Ready to use writer function. |
|
394 template<typename Graph, typename CapacityMap, typename CostMap> |
|
395 void writeGraph(std::ostream& os, const Graph &g, |
|
396 const CapacityMap& capacity, const typename Graph::Node &s, |
|
397 const typename Graph::Node &t) { |
|
398 GraphWriter<Graph> reader(os, g); |
|
399 IdMap<Graph, typename Graph::Node> nodeIdMap(g); |
|
400 reader.addNodeMap("id", nodeIdMap); |
|
401 IdMap<Graph, typename Graph::Edge> edgeIdMap(g); |
|
402 reader.addEdgeMap("id", edgeIdMap); |
|
403 reader.addEdgeMap("capacity", capacity); |
|
404 reader.addNode("source", s); |
|
405 reader.addNode("target", t); |
|
406 reader.run(); |
|
407 } |
|
408 |
|
409 /// Ready to use writer function. |
|
410 template<typename Graph, typename CapacityMap> |
|
411 void writeGraph(std::ostream& os, const Graph &g, |
|
412 const CapacityMap& capacity, const typename Graph::Node &s) { |
|
413 GraphWriter<Graph> reader(os, g); |
|
414 IdMap<Graph, typename Graph::Node> nodeIdMap(g); |
|
415 reader.addNodeMap("id", nodeIdMap); |
|
416 IdMap<Graph, typename Graph::Edge> edgeIdMap(g); |
|
417 reader.addEdgeMap("id", edgeIdMap); |
|
418 reader.addEdgeMap("capacity", capacity); |
|
419 reader.addNode("source", s); |
|
420 reader.run(); |
|
421 } |
|
422 /// Ready to use writer function. |
|
423 template<typename Graph, typename CapacityMap> |
|
424 void writeGraph(std::ostream& os, const Graph &g, |
|
425 const CapacityMap& capacity) { |
|
426 GraphWriter<Graph> reader(os, g); |
|
427 IdMap<Graph, typename Graph::Node> nodeIdMap(g); |
|
428 reader.addNodeMap("id", nodeIdMap); |
|
429 IdMap<Graph, typename Graph::Edge> edgeIdMap(g); |
|
430 reader.addEdgeMap("id", edgeIdMap); |
|
431 reader.addEdgeMap("capacity", capacity); |
|
432 reader.run(); |
|
433 } |
|
434 /// Ready to use writer function. |
|
435 template<typename Graph> |
|
436 void writeGraph(std::ostream& os, const Graph &g) { |
|
437 GraphWriter<Graph> reader(os, g); |
|
438 IdMap<Graph, typename Graph::Node> nodeIdMap(g); |
|
439 reader.addNodeMap("id", nodeIdMap); |
|
440 IdMap<Graph, typename Graph::Edge> edgeIdMap(g); |
|
441 reader.addEdgeMap("id", edgeIdMap); |
|
442 reader.run(); |
|
443 } |
|
444 |
374 |
445 |
375 } |
446 } |