COIN-OR::LEMON - Graph Library

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


Ignore:
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • demo/lgf_demo.cc

    r294 r290  
    4545
    4646  try {
    47     digraphReader(g, "digraph.lgf"). // read the directed graph into g
     47    digraphReader("digraph.lgf", g). // 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(g).                // write g to the standard output
     63  digraphWriter(std::cout, 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

    r294 r291  
    393393
    394394  template <typename Digraph>
    395   DigraphReader<Digraph> digraphReader(Digraph& digraph,
    396                                        std::istream& is = std::cin);
     395  DigraphReader<Digraph> digraphReader(std::istream& is, Digraph& digraph);
    397396
    398397  template <typename Digraph>
    399   DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn);
     398  DigraphReader<Digraph> digraphReader(const std::string& fn, Digraph& digraph);
    400399
    401400  template <typename Digraph>
    402   DigraphReader<Digraph> digraphReader(Digraph& digraph, const char *fn);
     401  DigraphReader<Digraph> digraphReader(const char *fn, Digraph& digraph);
    403402
    404403  /// \ingroup lemon_io
     
    423422  ///
    424423  ///\code
    425   /// DigraphReader<Digraph>(digraph, std::cin).
     424  /// DigraphReader<Digraph>(std::cin, digraph).
    426425  ///   nodeMap("coordinates", coord_map).
    427426  ///   arcMap("capacity", cap_map).
     
    504503    /// Construct a directed graph reader, which reads from the given
    505504    /// input stream.
    506     DigraphReader(Digraph& digraph, std::istream& is = std::cin)
     505    DigraphReader(std::istream& is, Digraph& digraph)
    507506      : _is(&is), local_is(false), _digraph(digraph),
    508507        _use_nodes(false), _use_arcs(false),
     
    513512    /// Construct a directed graph reader, which reads from the given
    514513    /// file.
    515     DigraphReader(Digraph& digraph, const std::string& fn)
     514    DigraphReader(const std::string& fn, Digraph& digraph)
    516515      : _is(new std::ifstream(fn.c_str())), local_is(true),
    517516        _filename(fn), _digraph(digraph),
     
    525524    /// Construct a directed graph reader, which reads from the given
    526525    /// file.
    527     DigraphReader(Digraph& digraph, const char* fn)
     526    DigraphReader(const char* fn, Digraph& digraph)
    528527      : _is(new std::ifstream(fn)), local_is(true),
    529528        _filename(fn), _digraph(digraph),
     
    558557  private:
    559558
    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);
     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);
    566565
    567566    DigraphReader(DigraphReader& other)
     
    11891188  /// \relates DigraphReader
    11901189  template <typename Digraph>
    1191   DigraphReader<Digraph> digraphReader(Digraph& digraph,
    1192                                        std::istream& is = std::cin) {
    1193     DigraphReader<Digraph> tmp(digraph, is);
     1190  DigraphReader<Digraph> digraphReader(std::istream& is, Digraph& digraph) {
     1191    DigraphReader<Digraph> tmp(is, digraph);
    11941192    return tmp;
    11951193  }
     
    12001198  /// \relates DigraphReader
    12011199  template <typename Digraph>
    1202   DigraphReader<Digraph> digraphReader(Digraph& digraph,
    1203                                        const std::string& fn) {
    1204     DigraphReader<Digraph> tmp(digraph, fn);
     1200  DigraphReader<Digraph> digraphReader(const std::string& fn,
     1201                                       Digraph& digraph) {
     1202    DigraphReader<Digraph> tmp(fn, digraph);
    12051203    return tmp;
    12061204  }
     
    12111209  /// \relates DigraphReader
    12121210  template <typename Digraph>
    1213   DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) {
    1214     DigraphReader<Digraph> tmp(digraph, fn);
     1211  DigraphReader<Digraph> digraphReader(const char* fn, Digraph& digraph) {
     1212    DigraphReader<Digraph> tmp(fn, digraph);
    12151213    return tmp;
    12161214  }
     
    12201218
    12211219  template <typename Graph>
    1222   GraphReader<Graph> graphReader(Graph& graph,
    1223                                  std::istream& is = std::cin);
     1220  GraphReader<Graph> graphReader(std::istream& is, Graph& graph);
    12241221
    12251222  template <typename Graph>
    1226   GraphReader<Graph> graphReader(Graph& graph, const std::string& fn);
     1223  GraphReader<Graph> graphReader(const std::string& fn, Graph& graph);
    12271224
    12281225  template <typename Graph>
    1229   GraphReader<Graph> graphReader(Graph& graph, const char *fn);
     1226  GraphReader<Graph> graphReader(const char *fn, Graph& graph);
    12301227
    12311228  /// \ingroup lemon_io
     
    12951292    /// Construct an undirected graph reader, which reads from the given
    12961293    /// input stream.
    1297     GraphReader(Graph& graph, std::istream& is = std::cin)
     1294    GraphReader(std::istream& is, Graph& graph)
    12981295      : _is(&is), local_is(false), _graph(graph),
    12991296        _use_nodes(false), _use_edges(false),
     
    13041301    /// Construct an undirected graph reader, which reads from the given
    13051302    /// file.
    1306     GraphReader(Graph& graph, const std::string& fn)
     1303    GraphReader(const std::string& fn, Graph& graph)
    13071304      : _is(new std::ifstream(fn.c_str())), local_is(true),
    13081305        _filename(fn), _graph(graph),
     
    13161313    /// Construct an undirected graph reader, which reads from the given
    13171314    /// file.
    1318     GraphReader(Graph& graph, const char* fn)
     1315    GraphReader(const char* fn, Graph& graph)
    13191316      : _is(new std::ifstream(fn)), local_is(true),
    13201317        _filename(fn), _graph(graph),
     
    13481345
    13491346  private:
    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);
     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);
    13541351
    13551352    GraphReader(GraphReader& other)
     
    20252022  /// \relates GraphReader
    20262023  template <typename Graph>
    2027   GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) {
    2028     GraphReader<Graph> tmp(graph, is);
     2024  GraphReader<Graph> graphReader(std::istream& is, Graph& graph) {
     2025    GraphReader<Graph> tmp(is, graph);
    20292026    return tmp;
    20302027  }
     
    20352032  /// \relates GraphReader
    20362033  template <typename Graph>
    2037   GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) {
    2038     GraphReader<Graph> tmp(graph, fn);
     2034  GraphReader<Graph> graphReader(const std::string& fn,
     2035                                       Graph& graph) {
     2036    GraphReader<Graph> tmp(fn, graph);
    20392037    return tmp;
    20402038  }
     
    20452043  /// \relates GraphReader
    20462044  template <typename Graph>
    2047   GraphReader<Graph> graphReader(Graph& graph, const char* fn) {
    2048     GraphReader<Graph> tmp(graph, fn);
     2045  GraphReader<Graph> graphReader(const char* fn, Graph& graph) {
     2046    GraphReader<Graph> tmp(fn, graph);
    20492047    return tmp;
    20502048  }
  • lemon/lgf_writer.h

    r294 r291  
    353353
    354354  template <typename Digraph>
    355   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    356                                        std::ostream& os = std::cout);
     355  DigraphWriter<Digraph> digraphWriter(std::ostream& os,
     356                                       const Digraph& digraph);
    357357
    358358  template <typename Digraph>
    359   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    360                                        const std::string& fn);
     359  DigraphWriter<Digraph> digraphWriter(const std::string& fn,
     360                                       const Digraph& digraph);
    361361
    362362  template <typename Digraph>
    363   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    364                                        const char *fn);
     363  DigraphWriter<Digraph> digraphWriter(const char *fn,
     364                                       const Digraph& digraph);
    365365
    366366  /// \ingroup lemon_io
     
    383383  ///
    384384  ///\code
    385   /// DigraphWriter<Digraph>(digraph, std::cout).
     385  /// DigraphWriter<Digraph>(std::cout, digraph).
    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(const Digraph& digraph, std::ostream& os = std::cout)
    456       : _os(&os), local_os(false), _digraph(digraph),
     455    DigraphWriter(std::ostream& is, const Digraph& digraph)
     456      : _os(&is), 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 Digraph& digraph, const std::string& fn)
     463    DigraphWriter(const std::string& fn, const Digraph& digraph)
    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 Digraph& digraph, const char* fn)
     473    DigraphWriter(const char* fn, const Digraph& digraph)
    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<>(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);
     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);
    509509
    510510    DigraphWriter(DigraphWriter& other)
     
    913913  /// \relates DigraphWriter
    914914  template <typename Digraph>
    915   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    916                                        std::ostream& os = std::cout) {
    917     DigraphWriter<Digraph> tmp(digraph, os);
     915  DigraphWriter<Digraph> digraphWriter(std::ostream& os,
     916                                       const Digraph& digraph) {
     917    DigraphWriter<Digraph> tmp(os, digraph);
    918918    return tmp;
    919919  }
     
    924924  /// \relates DigraphWriter
    925925  template <typename Digraph>
    926   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    927                                        const std::string& fn) {
    928     DigraphWriter<Digraph> tmp(digraph, fn);
     926  DigraphWriter<Digraph> digraphWriter(const std::string& fn,
     927                                       const Digraph& digraph) {
     928    DigraphWriter<Digraph> tmp(fn, digraph);
    929929    return tmp;
    930930  }
     
    935935  /// \relates DigraphWriter
    936936  template <typename Digraph>
    937   DigraphWriter<Digraph> digraphWriter(const Digraph& digraph,
    938                                        const char* fn) {
    939     DigraphWriter<Digraph> tmp(digraph, fn);
     937  DigraphWriter<Digraph> digraphWriter(const char* fn,
     938                                       const Digraph& digraph) {
     939    DigraphWriter<Digraph> tmp(fn, digraph);
    940940    return tmp;
    941941  }
     
    945945
    946946  template <typename Graph>
    947   GraphWriter<Graph> graphWriter(const Graph& graph,
    948                                  std::ostream& os = std::cout);
     947  GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph);
    949948
    950949  template <typename Graph>
    951   GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn);
     950  GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph);
    952951
    953952  template <typename Graph>
    954   GraphWriter<Graph> graphWriter(const Graph& graph, const char *fn);
     953  GraphWriter<Graph> graphWriter(const char *fn, const Graph& graph);
    955954
    956955  /// \ingroup lemon_io
     
    10141013    /// Construct a directed graph writer, which writes to the given
    10151014    /// output stream.
    1016     GraphWriter(const Graph& graph, std::ostream& os = std::cout)
    1017       : _os(&os), local_os(false), _graph(graph),
     1015    GraphWriter(std::ostream& is, const Graph& graph)
     1016      : _os(&is), local_os(false), _graph(graph),
    10181017        _skip_nodes(false), _skip_edges(false) {}
    10191018
     
    10221021    /// Construct a directed graph writer, which writes to the given
    10231022    /// output file.
    1024     GraphWriter(const Graph& graph, const std::string& fn)
     1023    GraphWriter(const std::string& fn, const Graph& graph)
    10251024      : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph),
    10261025        _skip_nodes(false), _skip_edges(false) {
     
    10321031    /// Construct a directed graph writer, which writes to the given
    10331032    /// output file.
    1034     GraphWriter(const Graph& graph, const char* fn)
     1033    GraphWriter(const char* fn, const Graph& graph)
    10351034      : _os(new std::ofstream(fn)), local_os(true), _graph(graph),
    10361035        _skip_nodes(false), _skip_edges(false) {
     
    10621061  private:
    10631062
    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);
     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);
    10701069
    10711070    GraphWriter(GraphWriter& other)
     
    15201519  /// \relates GraphWriter
    15211520  template <typename Graph>
    1522   GraphWriter<Graph> graphWriter(const Graph& graph,
    1523                                  std::ostream& os = std::cout) {
    1524     GraphWriter<Graph> tmp(graph, os);
     1521  GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph) {
     1522    GraphWriter<Graph> tmp(os, graph);
    15251523    return tmp;
    15261524  }
     
    15311529  /// \relates GraphWriter
    15321530  template <typename Graph>
    1533   GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) {
    1534     GraphWriter<Graph> tmp(graph, fn);
     1531  GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph) {
     1532    GraphWriter<Graph> tmp(fn, graph);
    15351533    return tmp;
    15361534  }
     
    15411539  /// \relates GraphWriter
    15421540  template <typename Graph>
    1543   GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) {
    1544     GraphWriter<Graph> tmp(graph, fn);
     1541  GraphWriter<Graph> graphWriter(const char* fn, const Graph& graph) {
     1542    GraphWriter<Graph> tmp(fn, graph);
    15451543    return tmp;
    15461544  }
  • test/bfs_test.cc

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

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

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

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