COIN-OR::LEMON - Graph Library

Changes in / [292:e7af73f1805e:294:cbe3ec2d59d2] in lemon-1.2


Ignore:
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • demo/lgf_demo.cc

    r290 r294  
    4545
    4646  try {
    47     digraphReader("digraph.lgf", g). // read the directed graph into g
     47    digraphReader(g, "digraph.lgf"). // read the directed graph into g
    4848      arcMap("capacity", cap).       // read the 'capacity' arc map into cap
    4949      node("source", s).             // read 'source' node to s
     
    6161  std::cout << "We can write it to the standard output:" << std::endl;
    6262
    63   digraphWriter(std::cout, g).     // write g to the standard output
     63  digraphWriter(g).                // write g to the standard output
    6464    arcMap("capacity", cap).       // write cap into 'capacity'
    6565    node("source", s).             // write s to 'source'
  • lemon/lgf_reader.h

    r291 r294  
    393393
    394394  template <typename Digraph>
    395   DigraphReader<Digraph> digraphReader(std::istream& is, Digraph& digraph);
     395  DigraphReader<Digraph> digraphReader(Digraph& digraph,
     396                                       std::istream& is = std::cin);
    396397
    397398  template <typename Digraph>
    398   DigraphReader<Digraph> digraphReader(const std::string& fn, Digraph& digraph);
     399  DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn);
    399400
    400401  template <typename Digraph>
    401   DigraphReader<Digraph> digraphReader(const char *fn, Digraph& digraph);
     402  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char *fn);
    402403
    403404  /// \ingroup lemon_io
     
    422423  ///
    423424  ///\code
    424   /// DigraphReader<Digraph>(std::cin, digraph).
     425  /// DigraphReader<Digraph>(digraph, std::cin).
    425426  ///   nodeMap("coordinates", coord_map).
    426427  ///   arcMap("capacity", cap_map).
     
    503504    /// Construct a directed graph reader, which reads from the given
    504505    /// input stream.
    505     DigraphReader(std::istream& is, Digraph& digraph)
     506    DigraphReader(Digraph& digraph, std::istream& is = std::cin)
    506507      : _is(&is), local_is(false), _digraph(digraph),
    507508        _use_nodes(false), _use_arcs(false),
     
    512513    /// Construct a directed graph reader, which reads from the given
    513514    /// file.
    514     DigraphReader(const std::string& fn, Digraph& digraph)
     515    DigraphReader(Digraph& digraph, const std::string& fn)
    515516      : _is(new std::ifstream(fn.c_str())), local_is(true),
    516517        _filename(fn), _digraph(digraph),
     
    524525    /// Construct a directed graph reader, which reads from the given
    525526    /// file.
    526     DigraphReader(const char* fn, Digraph& digraph)
     527    DigraphReader(Digraph& digraph, const char* fn)
    527528      : _is(new std::ifstream(fn)), local_is(true),
    528529        _filename(fn), _digraph(digraph),
     
    557558  private:
    558559
    559     friend DigraphReader<Digraph> digraphReader<>(std::istream& is,
    560                                                   Digraph& digraph);
    561     friend DigraphReader<Digraph> digraphReader<>(const std::string& fn,
    562                                                   Digraph& digraph);
    563     friend DigraphReader<Digraph> digraphReader<>(const char *fn,
    564                                                   Digraph& digraph);
     560    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
     561                                                  std::istream& is);
     562    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
     563                                                  const std::string& fn);
     564    friend DigraphReader<Digraph> digraphReader<>(Digraph& digraph,
     565                                                  const char *fn);
    565566
    566567    DigraphReader(DigraphReader& other)
     
    11881189  /// \relates DigraphReader
    11891190  template <typename Digraph>
    1190   DigraphReader<Digraph> digraphReader(std::istream& is, Digraph& digraph) {
    1191     DigraphReader<Digraph> tmp(is, digraph);
     1191  DigraphReader<Digraph> digraphReader(Digraph& digraph,
     1192                                       std::istream& is = std::cin) {
     1193    DigraphReader<Digraph> tmp(digraph, is);
    11921194    return tmp;
    11931195  }
     
    11981200  /// \relates DigraphReader
    11991201  template <typename Digraph>
    1200   DigraphReader<Digraph> digraphReader(const std::string& fn,
    1201                                        Digraph& digraph) {
    1202     DigraphReader<Digraph> tmp(fn, digraph);
     1202  DigraphReader<Digraph> digraphReader(Digraph& digraph,
     1203                                       const std::string& fn) {
     1204    DigraphReader<Digraph> tmp(digraph, fn);
    12031205    return tmp;
    12041206  }
     
    12091211  /// \relates DigraphReader
    12101212  template <typename Digraph>
    1211   DigraphReader<Digraph> digraphReader(const char* fn, Digraph& digraph) {
    1212     DigraphReader<Digraph> tmp(fn, digraph);
     1213  DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
     1214    DigraphReader<Digraph> tmp(digraph, fn);
    12131215    return tmp;
    12141216  }
     
    12181220
    12191221  template <typename Graph>
    1220   GraphReader<Graph> graphReader(std::istream& is, Graph& graph);
     1222  GraphReader<Graph> graphReader(Graph& graph,
     1223                                 std::istream& is = std::cin);
    12211224
    12221225  template <typename Graph>
    1223   GraphReader<Graph> graphReader(const std::string& fn, Graph& graph);
     1226  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn);
    12241227
    12251228  template <typename Graph>
    1226   GraphReader<Graph> graphReader(const char *fn, Graph& graph);
     1229  GraphReader<Graph> graphReader(Graph& graph, const char *fn);
    12271230
    12281231  /// \ingroup lemon_io
     
    12921295    /// Construct an undirected graph reader, which reads from the given
    12931296    /// input stream.
    1294     GraphReader(std::istream& is, Graph& graph)
     1297    GraphReader(Graph& graph, std::istream& is = std::cin)
    12951298      : _is(&is), local_is(false), _graph(graph),
    12961299        _use_nodes(false), _use_edges(false),
     
    13011304    /// Construct an undirected graph reader, which reads from the given
    13021305    /// file.
    1303     GraphReader(const std::string& fn, Graph& graph)
     1306    GraphReader(Graph& graph, const std::string& fn)
    13041307      : _is(new std::ifstream(fn.c_str())), local_is(true),
    13051308        _filename(fn), _graph(graph),
     
    13131316    /// Construct an undirected graph reader, which reads from the given
    13141317    /// file.
    1315     GraphReader(const char* fn, Graph& graph)
     1318    GraphReader(Graph& graph, const char* fn)
    13161319      : _is(new std::ifstream(fn)), local_is(true),
    13171320        _filename(fn), _graph(graph),
     
    13451348
    13461349  private:
    1347     friend GraphReader<Graph> graphReader<>(std::istream& is, Graph& graph);
    1348     friend GraphReader<Graph> graphReader<>(const std::string& fn,
    1349                                             Graph& graph);
    1350     friend GraphReader<Graph> graphReader<>(const char *fn, Graph& graph);
     1350    friend GraphReader<Graph> graphReader<>(Graph& graph, std::istream& is);
     1351    friend GraphReader<Graph> graphReader<>(Graph& graph,
     1352                                            const std::string& fn);
     1353    friend GraphReader<Graph> graphReader<>(Graph& graph, const char *fn);
    13511354
    13521355    GraphReader(GraphReader& other)
     
    20222025  /// \relates GraphReader
    20232026  template <typename Graph>
    2024   GraphReader<Graph> graphReader(std::istream& is, Graph& graph) {
    2025     GraphReader<Graph> tmp(is, graph);
     2027  GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) {
     2028    GraphReader<Graph> tmp(graph, is);
    20262029    return tmp;
    20272030  }
     
    20322035  /// \relates GraphReader
    20332036  template <typename Graph>
    2034   GraphReader<Graph> graphReader(const std::string& fn,
    2035                                        Graph& graph) {
    2036     GraphReader<Graph> tmp(fn, graph);
     2037  GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
     2038    GraphReader<Graph> tmp(graph, fn);
    20372039    return tmp;
    20382040  }
     
    20432045  /// \relates GraphReader
    20442046  template <typename Graph>
    2045   GraphReader<Graph> graphReader(const char* fn, Graph& graph) {
    2046     GraphReader<Graph> tmp(fn, graph);
     2047  GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
     2048    GraphReader<Graph> tmp(graph, fn);
    20472049    return tmp;
    20482050  }
  • lemon/lgf_writer.h

    r291 r294  
    353353
    354354  template <typename Digraph>
    355   DigraphWriter<Digraph> digraphWriter(std::ostream& os,
    356                                        const Digraph& digraph);
     355  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
     356                                       std::ostream& os = std::cout);
    357357
    358358  template <typename Digraph>
    359   DigraphWriter<Digraph> digraphWriter(const std::string& fn,
    360                                        const Digraph& digraph);
     359  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
     360                                       const std::string& fn);
    361361
    362362  template <typename Digraph>
    363   DigraphWriter<Digraph> digraphWriter(const char *fn,
    364                                        const Digraph& digraph);
     363  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
     364                                       const char *fn);
    365365
    366366  /// \ingroup lemon_io
     
    383383  ///
    384384  ///\code
    385   /// DigraphWriter<Digraph>(std::cout, digraph).
     385  /// DigraphWriter<Digraph>(digraph, std::cout).
    386386  ///   nodeMap("coordinates", coord_map).
    387387  ///   nodeMap("size", size).
     
    453453    /// Construct a directed graph writer, which writes to the given
    454454    /// output stream.
    455     DigraphWriter(std::ostream& is, const Digraph& digraph)
    456       : _os(&is), local_os(false), _digraph(digraph),
     455    DigraphWriter(const Digraph& digraph, std::ostream& os = std::cout)
     456      : _os(&os), local_os(false), _digraph(digraph),
    457457        _skip_nodes(false), _skip_arcs(false) {}
    458458
     
    461461    /// Construct a directed graph writer, which writes to the given
    462462    /// output file.
    463     DigraphWriter(const std::string& fn, const Digraph& digraph)
     463    DigraphWriter(const Digraph& digraph, const std::string& fn)
    464464      : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph),
    465465        _skip_nodes(false), _skip_arcs(false) {
     
    471471    /// Construct a directed graph writer, which writes to the given
    472472    /// output file.
    473     DigraphWriter(const char* fn, const Digraph& digraph)
     473    DigraphWriter(const Digraph& digraph, const char* fn)
    474474      : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph),
    475475        _skip_nodes(false), _skip_arcs(false) {
     
    501501  private:
    502502
    503     friend DigraphWriter<Digraph> digraphWriter<>(std::ostream& os,
    504                                                   const Digraph& digraph);
    505     friend DigraphWriter<Digraph> digraphWriter<>(const std::string& fn,
    506                                                   const Digraph& digraph);
    507     friend DigraphWriter<Digraph> digraphWriter<>(const char *fn,
    508                                                   const Digraph& digraph);
     503    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
     504                                                  std::ostream& os);
     505    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
     506                                                  const std::string& fn);
     507    friend DigraphWriter<Digraph> digraphWriter<>(const Digraph& digraph,
     508                                                  const char *fn);
    509509
    510510    DigraphWriter(DigraphWriter& other)
     
    913913  /// \relates DigraphWriter
    914914  template <typename Digraph>
    915   DigraphWriter<Digraph> digraphWriter(std::ostream& os,
    916                                        const Digraph& digraph) {
    917     DigraphWriter<Digraph> tmp(os, digraph);
     915  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
     916                                       std::ostream& os = std::cout) {
     917    DigraphWriter<Digraph> tmp(digraph, os);
    918918    return tmp;
    919919  }
     
    924924  /// \relates DigraphWriter
    925925  template <typename Digraph>
    926   DigraphWriter<Digraph> digraphWriter(const std::string& fn,
    927                                        const Digraph& digraph) {
    928     DigraphWriter<Digraph> tmp(fn, digraph);
     926  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
     927                                       const std::string& fn) {
     928    DigraphWriter<Digraph> tmp(digraph, fn);
    929929    return tmp;
    930930  }
     
    935935  /// \relates DigraphWriter
    936936  template <typename Digraph>
    937   DigraphWriter<Digraph> digraphWriter(const char* fn,
    938                                        const Digraph& digraph) {
    939     DigraphWriter<Digraph> tmp(fn, digraph);
     937  DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
     938                                       const char* fn) {
     939    DigraphWriter<Digraph> tmp(digraph, fn);
    940940    return tmp;
    941941  }
     
    945945
    946946  template <typename Graph>
    947   GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph);
     947  GraphWriter<Graph> graphWriter(const Graph& graph,
     948                                 std::ostream& os = std::cout);
    948949
    949950  template <typename Graph>
    950   GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph);
     951  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn);
    951952
    952953  template <typename Graph>
    953   GraphWriter<Graph> graphWriter(const char *fn, const Graph& graph);
     954  GraphWriter<Graph> graphWriter(const Graph& graph, const char *fn);
    954955
    955956  /// \ingroup lemon_io
     
    10131014    /// Construct a directed graph writer, which writes to the given
    10141015    /// output stream.
    1015     GraphWriter(std::ostream& is, const Graph& graph)
    1016       : _os(&is), local_os(false), _graph(graph),
     1016    GraphWriter(const Graph& graph, std::ostream& os = std::cout)
     1017      : _os(&os), local_os(false), _graph(graph),
    10171018        _skip_nodes(false), _skip_edges(false) {}
    10181019
     
    10211022    /// Construct a directed graph writer, which writes to the given
    10221023    /// output file.
    1023     GraphWriter(const std::string& fn, const Graph& graph)
     1024    GraphWriter(const Graph& graph, const std::string& fn)
    10241025      : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph),
    10251026        _skip_nodes(false), _skip_edges(false) {
     
    10311032    /// Construct a directed graph writer, which writes to the given
    10321033    /// output file.
    1033     GraphWriter(const char* fn, const Graph& graph)
     1034    GraphWriter(const Graph& graph, const char* fn)
    10341035      : _os(new std::ofstream(fn)), local_os(true), _graph(graph),
    10351036        _skip_nodes(false), _skip_edges(false) {
     
    10611062  private:
    10621063
    1063     friend GraphWriter<Graph> graphWriter<>(std::ostream& os,
    1064                                             const Graph& graph);
    1065     friend GraphWriter<Graph> graphWriter<>(const std::string& fn,
    1066                                             const Graph& graph);
    1067     friend GraphWriter<Graph> graphWriter<>(const char *fn,
    1068                                             const Graph& graph);
     1064    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
     1065                                            std::ostream& os);
     1066    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
     1067                                            const std::string& fn);
     1068    friend GraphWriter<Graph> graphWriter<>(const Graph& graph,
     1069                                            const char *fn);
    10691070
    10701071    GraphWriter(GraphWriter& other)
     
    15191520  /// \relates GraphWriter
    15201521  template <typename Graph>
    1521   GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph) {
    1522     GraphWriter<Graph> tmp(os, graph);
     1522  GraphWriter<Graph> graphWriter(const Graph& graph,
     1523                                 std::ostream& os = std::cout) {
     1524    GraphWriter<Graph> tmp(graph, os);
    15231525    return tmp;
    15241526  }
     
    15291531  /// \relates GraphWriter
    15301532  template <typename Graph>
    1531   GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph) {
    1532     GraphWriter<Graph> tmp(fn, graph);
     1533  GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
     1534    GraphWriter<Graph> tmp(graph, fn);
    15331535    return tmp;
    15341536  }
     
    15391541  /// \relates GraphWriter
    15401542  template <typename Graph>
    1541   GraphWriter<Graph> graphWriter(const char* fn, const Graph& graph) {
    1542     GraphWriter<Graph> tmp(fn, graph);
     1543  GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
     1544    GraphWriter<Graph> tmp(graph, fn);
    15431545    return tmp;
    15441546  }
  • test/bfs_test.cc

    r286 r293  
    145145
    146146  std::istringstream input(test_lgf);
    147   digraphReader(input, G).
     147  digraphReader(G, input).
    148148    node("source", s).
    149149    node("target", t).
  • test/dfs_test.cc

    r286 r293  
    147147
    148148  std::istringstream input(test_lgf);
    149   digraphReader(input, G).
     149  digraphReader(G, input).
    150150    node("source", s).
    151151    node("target", t).
  • test/dijkstra_test.cc

    r286 r293  
    143143
    144144  std::istringstream input(test_lgf);
    145   digraphReader(input, G).
     145  digraphReader(G, input).
    146146    arcMap("length", length).
    147147    node("source", s).
  • test/heap_test.cc

    r257 r293  
    168168
    169169  std::istringstream input(test_lgf);
    170   digraphReader(input, digraph).
     170  digraphReader(digraph, input).
    171171    arcMap("capacity", length).
    172172    node("source", source).
Note: See TracChangeset for help on using the changeset viewer.