COIN-OR::LEMON - Graph Library

Changeset 1394:f0c48d7fa73d in lemon-0.x for src/lemon/graph_writer.h


Ignore:
Timestamp:
04/27/05 12:44:58 (16 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.