350 |
350 |
351 template <typename Digraph> |
351 template <typename Digraph> |
352 class DigraphWriter; |
352 class DigraphWriter; |
353 |
353 |
354 template <typename Digraph> |
354 template <typename Digraph> |
355 DigraphWriter<Digraph> digraphWriter(std::ostream& os, |
355 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
356 const Digraph& digraph); |
356 std::ostream& os = std::cout); |
357 |
357 |
358 template <typename Digraph> |
358 template <typename Digraph> |
359 DigraphWriter<Digraph> digraphWriter(const std::string& fn, |
359 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
360 const Digraph& digraph); |
360 const std::string& fn); |
361 |
361 |
362 template <typename Digraph> |
362 template <typename Digraph> |
363 DigraphWriter<Digraph> digraphWriter(const char *fn, |
363 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
364 const Digraph& digraph); |
364 const char *fn); |
365 |
365 |
366 /// \ingroup lemon_io |
366 /// \ingroup lemon_io |
367 /// |
367 /// |
368 /// \brief \ref lgf-format "LGF" writer for directed graphs |
368 /// \brief \ref lgf-format "LGF" writer for directed graphs |
369 /// |
369 /// |
380 /// the output stream. If the functor is not set, then a default |
380 /// the output stream. If the functor is not set, then a default |
381 /// conversion will be used. The \c attribute(), \c node() and \c |
381 /// conversion will be used. The \c attribute(), \c node() and \c |
382 /// arc() functions are used to add attribute writing rules. |
382 /// arc() functions are used to add attribute writing rules. |
383 /// |
383 /// |
384 ///\code |
384 ///\code |
385 /// DigraphWriter<Digraph>(std::cout, digraph). |
385 /// DigraphWriter<Digraph>(digraph, std::cout). |
386 /// nodeMap("coordinates", coord_map). |
386 /// nodeMap("coordinates", coord_map). |
387 /// nodeMap("size", size). |
387 /// nodeMap("size", size). |
388 /// nodeMap("title", title). |
388 /// nodeMap("title", title). |
389 /// arcMap("capacity", cap_map). |
389 /// arcMap("capacity", cap_map). |
390 /// node("source", src). |
390 /// node("source", src). |
450 |
450 |
451 /// \brief Constructor |
451 /// \brief Constructor |
452 /// |
452 /// |
453 /// Construct a directed graph writer, which writes to the given |
453 /// Construct a directed graph writer, which writes to the given |
454 /// output stream. |
454 /// output stream. |
455 DigraphWriter(std::ostream& is, const Digraph& digraph) |
455 DigraphWriter(const Digraph& digraph, std::ostream& os = std::cout) |
456 : _os(&is), local_os(false), _digraph(digraph), |
456 : _os(&os), local_os(false), _digraph(digraph), |
457 _skip_nodes(false), _skip_arcs(false) {} |
457 _skip_nodes(false), _skip_arcs(false) {} |
458 |
458 |
459 /// \brief Constructor |
459 /// \brief Constructor |
460 /// |
460 /// |
461 /// Construct a directed graph writer, which writes to the given |
461 /// Construct a directed graph writer, which writes to the given |
462 /// output file. |
462 /// output file. |
463 DigraphWriter(const std::string& fn, const Digraph& digraph) |
463 DigraphWriter(const Digraph& digraph, const std::string& fn) |
464 : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph), |
464 : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph), |
465 _skip_nodes(false), _skip_arcs(false) {} |
465 _skip_nodes(false), _skip_arcs(false) {} |
466 |
466 |
467 /// \brief Constructor |
467 /// \brief Constructor |
468 /// |
468 /// |
469 /// Construct a directed graph writer, which writes to the given |
469 /// Construct a directed graph writer, which writes to the given |
470 /// output file. |
470 /// output file. |
471 DigraphWriter(const char* fn, const Digraph& digraph) |
471 DigraphWriter(const Digraph& digraph, const char* fn) |
472 : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph), |
472 : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph), |
473 _skip_nodes(false), _skip_arcs(false) {} |
473 _skip_nodes(false), _skip_arcs(false) {} |
474 |
474 |
475 /// \brief Destructor |
475 /// \brief Destructor |
476 ~DigraphWriter() { |
476 ~DigraphWriter() { |
494 } |
494 } |
495 } |
495 } |
496 |
496 |
497 private: |
497 private: |
498 |
498 |
499 friend DigraphWriter<Digraph> digraphWriter<>(std::ostream& os, |
499 friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph, |
500 const Digraph& digraph); |
500 std::ostream& os); |
501 friend DigraphWriter<Digraph> digraphWriter<>(const std::string& fn, |
501 friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph, |
502 const Digraph& digraph); |
502 const std::string& fn); |
503 friend DigraphWriter<Digraph> digraphWriter<>(const char *fn, |
503 friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph, |
504 const Digraph& digraph); |
504 const char *fn); |
505 |
505 |
506 DigraphWriter(DigraphWriter& other) |
506 DigraphWriter(DigraphWriter& other) |
507 : _os(other._os), local_os(other.local_os), _digraph(other._digraph), |
507 : _os(other._os), local_os(other.local_os), _digraph(other._digraph), |
508 _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) { |
508 _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) { |
509 |
509 |
906 /// \brief Return a \ref DigraphWriter class |
906 /// \brief Return a \ref DigraphWriter class |
907 /// |
907 /// |
908 /// This function just returns a \ref DigraphWriter class. |
908 /// This function just returns a \ref DigraphWriter class. |
909 /// \relates DigraphWriter |
909 /// \relates DigraphWriter |
910 template <typename Digraph> |
910 template <typename Digraph> |
911 DigraphWriter<Digraph> digraphWriter(std::ostream& os, |
911 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
912 const Digraph& digraph) { |
912 std::ostream& os = std::cout) { |
913 DigraphWriter<Digraph> tmp(os, digraph); |
913 DigraphWriter<Digraph> tmp(digraph, os); |
914 return tmp; |
914 return tmp; |
915 } |
915 } |
916 |
916 |
917 /// \brief Return a \ref DigraphWriter class |
917 /// \brief Return a \ref DigraphWriter class |
918 /// |
918 /// |
919 /// This function just returns a \ref DigraphWriter class. |
919 /// This function just returns a \ref DigraphWriter class. |
920 /// \relates DigraphWriter |
920 /// \relates DigraphWriter |
921 template <typename Digraph> |
921 template <typename Digraph> |
922 DigraphWriter<Digraph> digraphWriter(const std::string& fn, |
922 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
923 const Digraph& digraph) { |
923 const std::string& fn) { |
924 DigraphWriter<Digraph> tmp(fn, digraph); |
924 DigraphWriter<Digraph> tmp(digraph, fn); |
925 return tmp; |
925 return tmp; |
926 } |
926 } |
927 |
927 |
928 /// \brief Return a \ref DigraphWriter class |
928 /// \brief Return a \ref DigraphWriter class |
929 /// |
929 /// |
930 /// This function just returns a \ref DigraphWriter class. |
930 /// This function just returns a \ref DigraphWriter class. |
931 /// \relates DigraphWriter |
931 /// \relates DigraphWriter |
932 template <typename Digraph> |
932 template <typename Digraph> |
933 DigraphWriter<Digraph> digraphWriter(const char* fn, |
933 DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
934 const Digraph& digraph) { |
934 const char* fn) { |
935 DigraphWriter<Digraph> tmp(fn, digraph); |
935 DigraphWriter<Digraph> tmp(digraph, fn); |
936 return tmp; |
936 return tmp; |
937 } |
937 } |
938 |
938 |
939 template <typename Graph> |
939 template <typename Graph> |
940 class GraphWriter; |
940 class GraphWriter; |
941 |
941 |
942 template <typename Graph> |
942 template <typename Graph> |
943 GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph); |
943 GraphWriter<Graph> graphWriter(const Graph& graph, |
|
944 std::ostream& os = std::cout); |
944 |
945 |
945 template <typename Graph> |
946 template <typename Graph> |
946 GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph); |
947 GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn); |
947 |
948 |
948 template <typename Graph> |
949 template <typename Graph> |
949 GraphWriter<Graph> graphWriter(const char *fn, const Graph& graph); |
950 GraphWriter<Graph> graphWriter(const Graph& graph, const char *fn); |
950 |
951 |
951 /// \ingroup lemon_io |
952 /// \ingroup lemon_io |
952 /// |
953 /// |
953 /// \brief \ref lgf-format "LGF" writer for directed graphs |
954 /// \brief \ref lgf-format "LGF" writer for directed graphs |
954 /// |
955 /// |
1006 |
1007 |
1007 /// \brief Constructor |
1008 /// \brief Constructor |
1008 /// |
1009 /// |
1009 /// Construct a directed graph writer, which writes to the given |
1010 /// Construct a directed graph writer, which writes to the given |
1010 /// output stream. |
1011 /// output stream. |
1011 GraphWriter(std::ostream& is, const Graph& graph) |
1012 GraphWriter(const Graph& graph, std::ostream& os = std::cout) |
1012 : _os(&is), local_os(false), _graph(graph), |
1013 : _os(&os), local_os(false), _graph(graph), |
1013 _skip_nodes(false), _skip_edges(false) {} |
1014 _skip_nodes(false), _skip_edges(false) {} |
1014 |
1015 |
1015 /// \brief Constructor |
1016 /// \brief Constructor |
1016 /// |
1017 /// |
1017 /// Construct a directed graph writer, which writes to the given |
1018 /// Construct a directed graph writer, which writes to the given |
1018 /// output file. |
1019 /// output file. |
1019 GraphWriter(const std::string& fn, const Graph& graph) |
1020 GraphWriter(const Graph& graph, const std::string& fn) |
1020 : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph), |
1021 : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph), |
1021 _skip_nodes(false), _skip_edges(false) {} |
1022 _skip_nodes(false), _skip_edges(false) {} |
1022 |
1023 |
1023 /// \brief Constructor |
1024 /// \brief Constructor |
1024 /// |
1025 /// |
1025 /// Construct a directed graph writer, which writes to the given |
1026 /// Construct a directed graph writer, which writes to the given |
1026 /// output file. |
1027 /// output file. |
1027 GraphWriter(const char* fn, const Graph& graph) |
1028 GraphWriter(const Graph& graph, const char* fn) |
1028 : _os(new std::ofstream(fn)), local_os(true), _graph(graph), |
1029 : _os(new std::ofstream(fn)), local_os(true), _graph(graph), |
1029 _skip_nodes(false), _skip_edges(false) {} |
1030 _skip_nodes(false), _skip_edges(false) {} |
1030 |
1031 |
1031 /// \brief Destructor |
1032 /// \brief Destructor |
1032 ~GraphWriter() { |
1033 ~GraphWriter() { |
1050 } |
1051 } |
1051 } |
1052 } |
1052 |
1053 |
1053 private: |
1054 private: |
1054 |
1055 |
1055 friend GraphWriter<Graph> graphWriter<>(std::ostream& os, |
1056 friend GraphWriter<Graph> graphWriter<>(const Graph& graph, |
1056 const Graph& graph); |
1057 std::ostream& os); |
1057 friend GraphWriter<Graph> graphWriter<>(const std::string& fn, |
1058 friend GraphWriter<Graph> graphWriter<>(const Graph& graph, |
1058 const Graph& graph); |
1059 const std::string& fn); |
1059 friend GraphWriter<Graph> graphWriter<>(const char *fn, |
1060 friend GraphWriter<Graph> graphWriter<>(const Graph& graph, |
1060 const Graph& graph); |
1061 const char *fn); |
1061 |
1062 |
1062 GraphWriter(GraphWriter& other) |
1063 GraphWriter(GraphWriter& other) |
1063 : _os(other._os), local_os(other.local_os), _graph(other._graph), |
1064 : _os(other._os), local_os(other.local_os), _graph(other._graph), |
1064 _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) { |
1065 _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) { |
1065 |
1066 |
1508 /// \brief Return a \ref GraphWriter class |
1509 /// \brief Return a \ref GraphWriter class |
1509 /// |
1510 /// |
1510 /// This function just returns a \ref GraphWriter class. |
1511 /// This function just returns a \ref GraphWriter class. |
1511 /// \relates GraphWriter |
1512 /// \relates GraphWriter |
1512 template <typename Graph> |
1513 template <typename Graph> |
1513 GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph) { |
1514 GraphWriter<Graph> graphWriter(const Graph& graph, |
1514 GraphWriter<Graph> tmp(os, graph); |
1515 std::ostream& os = std::cout) { |
|
1516 GraphWriter<Graph> tmp(graph, os); |
1515 return tmp; |
1517 return tmp; |
1516 } |
1518 } |
1517 |
1519 |
1518 /// \brief Return a \ref GraphWriter class |
1520 /// \brief Return a \ref GraphWriter class |
1519 /// |
1521 /// |
1520 /// This function just returns a \ref GraphWriter class. |
1522 /// This function just returns a \ref GraphWriter class. |
1521 /// \relates GraphWriter |
1523 /// \relates GraphWriter |
1522 template <typename Graph> |
1524 template <typename Graph> |
1523 GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph) { |
1525 GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) { |
1524 GraphWriter<Graph> tmp(fn, graph); |
1526 GraphWriter<Graph> tmp(graph, fn); |
1525 return tmp; |
1527 return tmp; |
1526 } |
1528 } |
1527 |
1529 |
1528 /// \brief Return a \ref GraphWriter class |
1530 /// \brief Return a \ref GraphWriter class |
1529 /// |
1531 /// |
1530 /// This function just returns a \ref GraphWriter class. |
1532 /// This function just returns a \ref GraphWriter class. |
1531 /// \relates GraphWriter |
1533 /// \relates GraphWriter |
1532 template <typename Graph> |
1534 template <typename Graph> |
1533 GraphWriter<Graph> graphWriter(const char* fn, const Graph& graph) { |
1535 GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) { |
1534 GraphWriter<Graph> tmp(fn, graph); |
1536 GraphWriter<Graph> tmp(graph, fn); |
1535 return tmp; |
1537 return tmp; |
1536 } |
1538 } |
1537 |
1539 |
1538 class SectionWriter; |
1540 class SectionWriter; |
1539 |
1541 |