COIN-OR::LEMON - Graph Library

Changeset 1394:f0c48d7fa73d in lemon-0.x


Ignore:
Timestamp:
04/27/05 12:44:58 (20 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1851
Message:

Modifying the interface.
add -> read, write

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • doc/graph_io.dox

    r1333 r1394  
    9090\endcode
    9191
    92 The \c addNodeMap() function declares a \c NodeMap writing command in the
     92The \c writeNodeMap() function declares a \c NodeMap writing command in the
    9393\c GraphWriter. You should give as parameter the name of the map and the map
    9494object. The NodeMap writing command with name "id" should write a
     
    9999\code
    100100IdMap<ListGraph, Node> nodeIdMap;
    101 writer.addNodeMap("id", nodeIdMap);
    102 
    103 writer.addNodeMap("x-coord", xCoordMap);
    104 writer.addNodeMap("y-coord", yCoordMap);
    105 writer.addNodeMap("color", colorMap);
    106 \endcode
    107 
    108 With the \c addEdgeMap() member function you can give an edge map
     101writer.writeNodeMap("id", nodeIdMap);
     102
     103writer.writeNodeMap("x-coord", xCoordMap);
     104writer.writeNodeMap("y-coord", yCoordMap);
     105writer.writeNodeMap("color", colorMap);
     106\endcode
     107
     108With the \c writeEdgeMap() member function you can give an edge map
    109109writing command similar to the NodeMaps.
    110110
     
    112112\code
    113113DescriptorMap<ListGraph, Edge, ListGraph::EdgeMap<int> > edgeDescMap(graph);
    114 writer.addEdgeMap("descriptor", edgeDescMap);
    115 
    116 writer.addEdgeMap("weight", weightMap);
    117 writer.addEdgeMap("label", labelMap);
    118 \endcode
    119 
    120 With \c addNode() and \c addEdge() functions you can point out Nodes and
     114writer.writeEdgeMap("descriptor", edgeDescMap);
     115
     116writer.writeEdgeMap("weight", weightMap);
     117writer.writeEdgeMap("label", labelMap);
     118\endcode
     119
     120With \c writeNode() and \c writeEdge() functions you can point out Nodes and
    121121Edges in the graph. By example, you can write out the source and target
    122122of the graph.
    123123
    124124\code
    125 writer.addNode("source", sourceNode);
    126 writer.addNode("target", targetNode);
    127 
    128 writer.addEdge("observed", edge);
     125writer.writeNode("source", sourceNode);
     126writer.writeNode("target", targetNode);
     127
     128writer.writeEdge("observed", edge);
    129129\endcode
    130130
     
    152152\endcode
    153153
    154 The \c addNodeMap() function reads a map from the \c \@nodeset section.
     154The \c readNodeMap() function reads a map from the \c \@nodeset section.
    155155If there is a map that you do not want to read from the file and there is
    156156whitespace in the string represenation of the values then you should
     
    159159\see QuotedStringReader
    160160\code
    161 reader.addNodeMap("x-coord", xCoordMap);
    162 reader.addNodeMap("y-coord", yCoordMap);
    163 
    164 reader.addNodeMap<QuotedStringReader>("label", labelMap);
     161reader.readNodeMap("x-coord", xCoordMap);
     162reader.readNodeMap("y-coord", yCoordMap);
     163
     164reader.readNodeMap<QuotedStringReader>("label", labelMap);
    165165reader.skipNodeMap<QuotedStringReader>("description");
    166166
    167 reader.addNodeMap("color", colorMap);
    168 \endcode
    169 
    170 With the \c addEdgeMap() member function you can give an edge map
     167reader.readNodeMap("color", colorMap);
     168\endcode
     169
     170With the \c readEdgeMap() member function you can give an edge map
    171171reading command similar to the NodeMaps.
    172172
    173173\code
    174 reader.addEdgeMap("weight", weightMap);
    175 reader.addEdgeMap("label", labelMap);
    176 \endcode
    177 
    178 With \c addNode() and \c addEdge() functions you can read labeled Nodes and
     174reader.readEdgeMap("weight", weightMap);
     175reader.readEdgeMap("label", labelMap);
     176\endcode
     177
     178With \c readNode() and \c readEdge() functions you can read labeled Nodes and
    179179Edges.
    180180
    181181\code
    182 reader.addNode("source", sourceNode);
    183 reader.addNode("target", targetNode);
    184 
    185 reader.addEdge("observed", edge);
     182reader.readNode("source", sourceNode);
     183reader.readNode("target", targetNode);
     184
     185reader.readEdge("observed", edge);
    186186\endcode
    187187
     
    231231};
    232232...
    233 reader.addNodeMap<LengthReader>("strings", lengthMap);
     233reader.readNodeMap<LengthReader>("strings", lengthMap);
    234234\endcode 
    235235
  • src/demo/lp_maxflow_demo.cc

    r1387 r1394  
    7676 
    7777  GraphReader<ListGraph> reader(std::cin,g);
    78   reader.addNode("source",s).addNode("target",t)
    79     .addEdgeMap("capacity",cap).run();
     78  reader.readNode("source",s).readNode("target",t)
     79    .readEdgeMap("capacity",cap).run();
    8080 
    8181  // std::ifstream file("../test/preflow_");
  • src/demo/min_route.cc

    r1358 r1394  
    7070  CoordMap coord(graph);
    7171  XMap<CoordMap> xcoord = xMap(coord);
    72   reader.addNodeMap("coordinates_x", xcoord);
     72  reader.readNodeMap("coordinates_x", xcoord);
    7373  YMap<CoordMap> ycoord = yMap(coord);
    74   reader.addNodeMap("coordinates_y", ycoord);
     74  reader.readNodeMap("coordinates_y", ycoord);
    7575
    7676  LengthMap length(graph);
    77   reader.addEdgeMap("length", length);
     77  reader.readEdgeMap("length", length);
    7878
    7979  Node source, target;
    80   reader.addNode("source", source);
    81   reader.addNode("target", target);
     80  reader.readNode("source", source);
     81  reader.readNode("target", target);
    8282
    8383  reader.run();
  • src/lemon/graph_reader.h

    r1359 r1394  
    201201  /// \endcode
    202202  ///
    203   /// The \c addNodeMap() function reads a map from the \c \@nodeset section.
     203  /// The \c readNodeMap() function reads a map from the \c \@nodeset section.
    204204  /// If there is a map that you do not want to read from the file and there is
    205205  /// whitespace in the string represenation of the values then you should
     
    208208  ///
    209209  /// \code
    210   /// reader.addNodeMap("x-coord", xCoordMap);
    211   /// reader.addNodeMap("y-coord", yCoordMap);
    212   ///
    213   /// reader.addNodeMap<QuotedStringReader>("label", labelMap);
     210  /// reader.readNodeMap("x-coord", xCoordMap);
     211  /// reader.readNodeMap("y-coord", yCoordMap);
     212  ///
     213  /// reader.readNodeMap<QuotedStringReader>("label", labelMap);
    214214  /// reader.skipNodeMap<QuotedStringReader>("description");
    215215  ///
    216   /// reader.addNodeMap("color", colorMap);
     216  /// reader.readNodeMap("color", colorMap);
    217217  /// \endcode
    218218  ///
    219   /// With the \c addEdgeMap() member function you can give an edge map
     219  /// With the \c readEdgeMap() member function you can give an edge map
    220220  /// reading command similar to the NodeMaps.
    221221  ///
    222222  /// \code
    223   /// reader.addEdgeMap("weight", weightMap);
    224   /// reader.addEdgeMap("label", labelMap);
     223  /// reader.readEdgeMap("weight", weightMap);
     224  /// reader.readEdgeMap("label", labelMap);
    225225  /// \endcode
    226226  ///
    227   /// With \c addNode() and \c addEdge() functions you can read labeled Nodes
     227  /// With \c readNode() and \c readEdge() functions you can read labeled Nodes
    228228  /// and Edges.
    229229  ///
    230230  /// \code
    231   /// reader.addNode("source", sourceNode);
    232   /// reader.addNode("target", targetNode);
    233   ///
    234   /// reader.addEdge("observed", edge);
     231  /// reader.readNode("source", sourceNode);
     232  /// reader.readNode("target", targetNode);
     233  ///
     234  /// reader.readEdge("observed", edge);
    235235  /// \endcode
    236236  ///
     
    286286    /// Add a new node map reader command for the reader.
    287287    template <typename Map>
    288     GraphReader& addNodeMap(std::string name, Map& map) {
    289       return addNodeMap<typename ReaderTraits::template
     288    GraphReader& readNodeMap(std::string name, Map& map) {
     289      return readNodeMap<typename ReaderTraits::template
    290290        Reader<typename Map::Value>, Map>(name, map);
    291291    }
     
    295295    /// Add a new node map reader command for the reader.
    296296    template <typename Reader, typename Map>
    297     GraphReader& addNodeMap(std::string name, Map& map,
     297    GraphReader& readNodeMap(std::string name, Map& map,
    298298                             const Reader& reader = Reader()) {
    299299      if (node_map_readers.find(name) != node_map_readers.end()) {
     
    327327    /// Add a new edge map reader command for the reader.
    328328    template <typename Map>
    329     GraphReader& addEdgeMap(std::string name, Map& map) {
    330       return addEdgeMap<typename ReaderTraits::template
     329    GraphReader& readEdgeMap(std::string name, Map& map) {
     330      return readEdgeMap<typename ReaderTraits::template
    331331        Reader<typename Map::Value>, Map>(name, map);
    332332    }
     
    337337    /// Add a new edge map reader command for the reader.
    338338    template <typename Reader, typename Map>
    339     GraphReader& addEdgeMap(std::string name, Map& map,
     339    GraphReader& readEdgeMap(std::string name, Map& map,
    340340                             const Reader& reader = Reader()) {
    341341      if (edge_map_readers.find(name) != edge_map_readers.end()) {
     
    368368    ///
    369369    /// Add a new labeled node reader for the reader.
    370     GraphReader& addNode(std::string name, Node& node) {
     370    GraphReader& readNode(std::string name, Node& node) {
    371371      if (node_readers.find(name) != node_readers.end()) {
    372372        ErrorMessage msg;
     
    381381    ///
    382382    /// Add a new labeled edge reader for the reader.
    383     GraphReader& addEdge(std::string name, Edge& edge) {
     383    GraphReader& readEdge(std::string name, Edge& edge) {
    384384      if (edge_readers.find(name) != edge_readers.end()) {
    385385        ErrorMessage msg;
     
    755755                  CostMap& cost) {
    756756    GraphReader<Graph> reader(is, g);
    757     reader.addEdgeMap("capacity", capacity);
    758     reader.addEdgeMap("cost", cost);
    759     reader.addNode("source", s);
    760     reader.addNode("target", t);
     757    reader.readEdgeMap("capacity", capacity);
     758    reader.readEdgeMap("cost", cost);
     759    reader.readNode("source", s);
     760    reader.readNode("target", t);
    761761    reader.run();
    762762  }
     
    774774                  typename Graph::Node &s, typename Graph::Node &t) {
    775775    GraphReader<Graph> reader(is, g);
    776     reader.addEdgeMap("capacity", capacity);
    777     reader.addNode("source", s);
    778     reader.addNode("target", t);
     776    reader.readEdgeMap("capacity", capacity);
     777    reader.readNode("source", s);
     778    reader.readNode("target", t);
    779779    reader.run();
    780780  }
     
    791791                  typename Graph::Node &s) {
    792792    GraphReader<Graph> reader(is, g);
    793     reader.addEdgeMap("capacity", capacity);
    794     reader.addNode("source", s);
     793    reader.readEdgeMap("capacity", capacity);
     794    reader.readNode("source", s);
    795795    reader.run();
    796796  }
     
    805805  void readGraph(std::istream& is, Graph &g, CapacityMap& capacity) {
    806806    GraphReader<Graph> reader(is, g);
    807     reader.addEdgeMap("capacity", capacity);
     807    reader.readEdgeMap("capacity", capacity);
    808808    reader.run();
    809809  }
  • src/lemon/graph_writer.h

    r1359 r1394  
    169169  /// \endcode
    170170  ///
    171   /// The \c addNodeMap() function declares a \c NodeMap writing command in the
    172   /// \c GraphWriter. You should give as parameter the name of the map and the
    173   /// map object. The NodeMap writing command with name "id" should write a
    174   /// unique map because it is regarded as ID map.
     171  /// The \c writeNodeMap() function declares a \c NodeMap writing
     172  /// command in the \c GraphWriter. You should give as parameter
     173  /// the name of the map and the map object. The NodeMap writing
     174  /// command with name "id" should write a unique map because it
     175  /// is regarded as ID map.
    175176  ///
    176177  /// \code
    177178  /// IdMap<ListGraph, Node> nodeIdMap;
    178   /// writer.addNodeMap("id", nodeIdMap);
    179   ///
    180   /// writer.addNodeMap("x-coord", xCoordMap);
    181   /// writer.addNodeMap("y-coord", yCoordMap);
    182   /// writer.addNodeMap("color", colorMap);
     179  /// writer.writeNodeMap("id", nodeIdMap);
     180  ///
     181  /// writer.writeNodeMap("x-coord", xCoordMap);
     182  /// writer.writeNodeMap("y-coord", yCoordMap);
     183  /// writer.writeNodeMap("color", colorMap);
    183184  /// \endcode
    184185  ///
    185   /// With the \c addEdgeMap() member function you can give an edge map
     186  /// With the \c writeEdgeMap() member function you can give an edge map
    186187  /// writing command similar to the NodeMaps.
    187188  ///
     
    189190  /// DescriptorMap<ListGraph, Edge, ListGraph::EdgeMap<int> >
    190191  ///   edgeDescMap(graph);
    191   /// writer.addEdgeMap("descriptor", edgeDescMap);
    192   ///
    193   /// writer.addEdgeMap("weight", weightMap);
    194   /// writer.addEdgeMap("label", labelMap);
     192  /// writer.writeEdgeMap("descriptor", edgeDescMap);
     193  ///
     194  /// writer.writeEdgeMap("weight", weightMap);
     195  /// writer.writeEdgeMap("label", labelMap);
    195196  /// \endcode
    196197  ///
    197   /// With \c addNode() and \c addEdge() functions you can point out Nodes and
    198   /// Edges in the graph. By example, you can write out the source and target
    199   /// of the graph.
     198  /// With \c writeNode() and \c writeEdge() functions you can
     199  /// point out Nodes and Edges in the graph. By example, you can
     200  /// write out the source and target of the graph.
    200201  ///
    201202  /// \code
    202   /// writer.addNode("source", sourceNode);
    203   /// writer.addNode("target", targetNode);
    204   ///
    205   /// writer.addEdge("observed", edge);
     203  /// writer.writeNode("source", sourceNode);
     204  /// writer.writeNode("target", targetNode);
     205  ///
     206  /// writer.writeEdge("observed", edge);
    206207  /// \endcode
    207208  ///
     
    217218  /// \see IdMap
    218219  /// \see DescriptorMap
    219   /// \see \ref GraphReader
     220  /// \see \ref GraphWriter
    220221  /// \see \ref graph-io-page
    221222  /// \author Balazs Dezso
     
    263264    /// Add a new node map writer command for the writer.
    264265    template <typename Map>
    265     GraphWriter& addNodeMap(std::string name, const Map& map) {
    266       return addNodeMap<typename WriterTraits::template Writer<
     266    GraphWriter& writeNodeMap(std::string name, const Map& map) {
     267      return writeNodeMap<typename WriterTraits::template Writer<
    267268        typename Map::Value>, Map>(name, map);
    268269    }
     
    272273    /// Add a new node map writer command for the writer.
    273274    template <typename Writer, typename Map>
    274     GraphWriter& addNodeMap(std::string name, const Map& map,
     275    GraphWriter& writeNodeMap(std::string name, const Map& map,
    275276                              const Writer& writer = Writer()) {
    276277      node_map_writers.push_back(
     
    285286    /// Add a new edge map writer command for the writer.
    286287    template <typename Map>
    287     GraphWriter& addEdgeMap(std::string name, const Map& map) {
    288       return addEdgeMap<typename WriterTraits::template Writer<
     288    GraphWriter& writeEdgeMap(std::string name, const Map& map) {
     289      return writeEdgeMap<typename WriterTraits::template Writer<
    289290        typename Map::Value>, Map>(name, map);
    290291    }
     
    295296    /// Add a new edge map writer command for the writer.
    296297    template <typename Writer, typename Map>
    297     GraphWriter& addEdgeMap(std::string name,
     298    GraphWriter& writeEdgeMap(std::string name,
    298299                            const Map& map, const Writer& writer = Writer()) {
    299300      edge_map_writers.push_back(make_pair(name,
     
    305306    ///
    306307    /// Add a new labeled node writer for the writer.
    307     GraphWriter& addNode(std::string name, const Node& node) {
     308    GraphWriter& writeNode(std::string name, const Node& node) {
    308309      node_writers.push_back(make_pair(name, node));
    309310      return *this;
     
    313314    ///
    314315    /// Add a new labeled edge writer for the writer.
    315     GraphWriter& addEdge(std::string name, const Edge& edge) {
     316    GraphWriter& writeEdge(std::string name, const Edge& edge) {
    316317      edge_writers.push_back(make_pair(name, edge));
    317318      return *this;
     
    468469                  const CapacityMap& capacity, const typename Graph::Node &s,
    469470                  const typename Graph::Node &t, const CostMap& cost) {
    470     GraphWriter<Graph> reader(os, g);
     471    GraphWriter<Graph> writer(os, g);
    471472    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
    472     reader.addNodeMap("id", nodeIdMap);
     473    writer.writeNodeMap("id", nodeIdMap);
    473474    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
    474     reader.addEdgeMap("id", edgeIdMap);
    475     reader.addEdgeMap("capacity", capacity);
    476     reader.addEdgeMap("cost", cost);
    477     reader.addNode("source", s);
    478     reader.addNode("target", t);
    479     reader.run();
     475    writer.writeEdgeMap("id", edgeIdMap);
     476    writer.writeEdgeMap("capacity", capacity);
     477    writer.writeEdgeMap("cost", cost);
     478    writer.writeNode("source", s);
     479    writer.writeNode("target", t);
     480    writer.run();
    480481  }
    481482
     
    492493                  const CapacityMap& capacity, const typename Graph::Node &s,
    493494                  const typename Graph::Node &t) {
    494     GraphWriter<Graph> reader(os, g);
     495    GraphWriter<Graph> writer(os, g);
    495496    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
    496     reader.addNodeMap("id", nodeIdMap);
     497    writer.writeNodeMap("id", nodeIdMap);
    497498    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
    498     reader.addEdgeMap("id", edgeIdMap);
    499     reader.addEdgeMap("capacity", capacity);
    500     reader.addNode("source", s);
    501     reader.addNode("target", t);
    502     reader.run();
     499    writer.writeEdgeMap("id", edgeIdMap);
     500    writer.writeEdgeMap("capacity", capacity);
     501    writer.writeNode("source", s);
     502    writer.writeNode("target", t);
     503    writer.run();
    503504  }
    504505
     
    513514  void writeGraph(std::ostream& os, const Graph &g,
    514515                  const CapacityMap& capacity, const typename Graph::Node &s) {
    515     GraphWriter<Graph> reader(os, g);
     516    GraphWriter<Graph> writer(os, g);
    516517    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
    517     reader.addNodeMap("id", nodeIdMap);
     518    writer.writeNodeMap("id", nodeIdMap);
    518519    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
    519     reader.addEdgeMap("id", edgeIdMap);
    520     reader.addEdgeMap("capacity", capacity);
    521     reader.addNode("source", s);
    522     reader.run();
     520    writer.writeEdgeMap("id", edgeIdMap);
     521    writer.writeEdgeMap("capacity", capacity);
     522    writer.writeNode("source", s);
     523    writer.run();
    523524  }
    524525
     
    532533  void writeGraph(std::ostream& os, const Graph &g,
    533534                  const CapacityMap& capacity) {
    534     GraphWriter<Graph> reader(os, g);
     535    GraphWriter<Graph> writer(os, g);
    535536    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
    536     reader.addNodeMap("id", nodeIdMap);
     537    writer.writeNodeMap("id", nodeIdMap);
    537538    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
    538     reader.addEdgeMap("id", edgeIdMap);
    539     reader.addEdgeMap("capacity", capacity);
    540     reader.run();
     539    writer.writeEdgeMap("id", edgeIdMap);
     540    writer.writeEdgeMap("capacity", capacity);
     541    writer.run();
    541542  }
    542543
     
    548549  template<typename Graph>
    549550  void writeGraph(std::ostream& os, const Graph &g) {
    550     GraphWriter<Graph> reader(os, g);
     551    GraphWriter<Graph> writer(os, g);
    551552    IdMap<Graph, typename Graph::Node> nodeIdMap(g);
    552     reader.addNodeMap("id", nodeIdMap);
     553    writer.writeNodeMap("id", nodeIdMap);
    553554    IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
    554     reader.addEdgeMap("id", edgeIdMap);
    555     reader.run();
     555    writer.writeEdgeMap("id", edgeIdMap);
     556    writer.run();
    556557  }
    557558
Note: See TracChangeset for help on using the changeset viewer.