# HG changeset patch # User deba # Date 1114598698 0 # Node ID f0c48d7fa73dcb78340e55d923903f4aacd286b3 # Parent 2edd8cd06eaf00836a91bffa957db25c8558c6ad Modifying the interface. add -> read, write diff -r 2edd8cd06eaf -r f0c48d7fa73d doc/graph_io.dox --- a/doc/graph_io.dox Wed Apr 27 10:42:58 2005 +0000 +++ b/doc/graph_io.dox Wed Apr 27 10:44:58 2005 +0000 @@ -89,7 +89,7 @@ GraphWriter writer(std::cout, graph); \endcode -The \c addNodeMap() function declares a \c NodeMap writing command in the +The \c writeNodeMap() function declares a \c NodeMap writing command in the \c GraphWriter. You should give as parameter the name of the map and the map object. The NodeMap writing command with name "id" should write a unique map because it is regarded as ID map. @@ -98,34 +98,34 @@ \code IdMap nodeIdMap; -writer.addNodeMap("id", nodeIdMap); +writer.writeNodeMap("id", nodeIdMap); -writer.addNodeMap("x-coord", xCoordMap); -writer.addNodeMap("y-coord", yCoordMap); -writer.addNodeMap("color", colorMap); +writer.writeNodeMap("x-coord", xCoordMap); +writer.writeNodeMap("y-coord", yCoordMap); +writer.writeNodeMap("color", colorMap); \endcode -With the \c addEdgeMap() member function you can give an edge map +With the \c writeEdgeMap() member function you can give an edge map writing command similar to the NodeMaps. \see IdMap, DescriptorMap \code DescriptorMap > edgeDescMap(graph); -writer.addEdgeMap("descriptor", edgeDescMap); +writer.writeEdgeMap("descriptor", edgeDescMap); -writer.addEdgeMap("weight", weightMap); -writer.addEdgeMap("label", labelMap); +writer.writeEdgeMap("weight", weightMap); +writer.writeEdgeMap("label", labelMap); \endcode -With \c addNode() and \c addEdge() functions you can point out Nodes and +With \c writeNode() and \c writeEdge() functions you can point out Nodes and Edges in the graph. By example, you can write out the source and target of the graph. \code -writer.addNode("source", sourceNode); -writer.addNode("target", targetNode); +writer.writeNode("source", sourceNode); +writer.writeNode("target", targetNode); -writer.addEdge("observed", edge); +writer.writeEdge("observed", edge); \endcode After you give all write commands you must call the \c run() member @@ -151,38 +151,38 @@ GraphReader reader(std::cin, graph); \endcode -The \c addNodeMap() function reads a map from the \c \@nodeset section. +The \c readNodeMap() function reads a map from the \c \@nodeset section. If there is a map that you do not want to read from the file and there is whitespace in the string represenation of the values then you should call the \c skipNodeMap() template member function with proper parameters. \see QuotedStringReader \code -reader.addNodeMap("x-coord", xCoordMap); -reader.addNodeMap("y-coord", yCoordMap); +reader.readNodeMap("x-coord", xCoordMap); +reader.readNodeMap("y-coord", yCoordMap); -reader.addNodeMap("label", labelMap); +reader.readNodeMap("label", labelMap); reader.skipNodeMap("description"); -reader.addNodeMap("color", colorMap); +reader.readNodeMap("color", colorMap); \endcode -With the \c addEdgeMap() member function you can give an edge map +With the \c readEdgeMap() member function you can give an edge map reading command similar to the NodeMaps. \code -reader.addEdgeMap("weight", weightMap); -reader.addEdgeMap("label", labelMap); +reader.readEdgeMap("weight", weightMap); +reader.readEdgeMap("label", labelMap); \endcode -With \c addNode() and \c addEdge() functions you can read labeled Nodes and +With \c readNode() and \c readEdge() functions you can read labeled Nodes and Edges. \code -reader.addNode("source", sourceNode); -reader.addNode("target", targetNode); +reader.readNode("source", sourceNode); +reader.readNode("target", targetNode); -reader.addEdge("observed", edge); +reader.readEdge("observed", edge); \endcode After you give all read commands you must call the \c run() member @@ -230,7 +230,7 @@ } }; ... -reader.addNodeMap("strings", lengthMap); +reader.readNodeMap("strings", lengthMap); \endcode The global functionality of the reader class can be changed by giving a diff -r 2edd8cd06eaf -r f0c48d7fa73d src/demo/lp_maxflow_demo.cc --- a/src/demo/lp_maxflow_demo.cc Wed Apr 27 10:42:58 2005 +0000 +++ b/src/demo/lp_maxflow_demo.cc Wed Apr 27 10:44:58 2005 +0000 @@ -75,8 +75,8 @@ ListGraph::EdgeMap cap(g); GraphReader reader(std::cin,g); - reader.addNode("source",s).addNode("target",t) - .addEdgeMap("capacity",cap).run(); + reader.readNode("source",s).readNode("target",t) + .readEdgeMap("capacity",cap).run(); // std::ifstream file("../test/preflow_"); // readDimacs(file, g, cap, s, t); diff -r 2edd8cd06eaf -r f0c48d7fa73d src/demo/min_route.cc --- a/src/demo/min_route.cc Wed Apr 27 10:42:58 2005 +0000 +++ b/src/demo/min_route.cc Wed Apr 27 10:44:58 2005 +0000 @@ -69,16 +69,16 @@ CoordMap coord(graph); XMap xcoord = xMap(coord); - reader.addNodeMap("coordinates_x", xcoord); + reader.readNodeMap("coordinates_x", xcoord); YMap ycoord = yMap(coord); - reader.addNodeMap("coordinates_y", ycoord); + reader.readNodeMap("coordinates_y", ycoord); LengthMap length(graph); - reader.addEdgeMap("length", length); + reader.readEdgeMap("length", length); Node source, target; - reader.addNode("source", source); - reader.addNode("target", target); + reader.readNode("source", source); + reader.readNode("target", target); reader.run(); diff -r 2edd8cd06eaf -r f0c48d7fa73d src/lemon/graph_reader.h --- a/src/lemon/graph_reader.h Wed Apr 27 10:42:58 2005 +0000 +++ b/src/lemon/graph_reader.h Wed Apr 27 10:44:58 2005 +0000 @@ -200,38 +200,38 @@ /// GraphReader reader(std::cin, graph); /// \endcode /// - /// The \c addNodeMap() function reads a map from the \c \@nodeset section. + /// The \c readNodeMap() function reads a map from the \c \@nodeset section. /// If there is a map that you do not want to read from the file and there is /// whitespace in the string represenation of the values then you should /// call the \c skipNodeMap() template member function with proper /// parameters. /// /// \code - /// reader.addNodeMap("x-coord", xCoordMap); - /// reader.addNodeMap("y-coord", yCoordMap); + /// reader.readNodeMap("x-coord", xCoordMap); + /// reader.readNodeMap("y-coord", yCoordMap); /// - /// reader.addNodeMap("label", labelMap); + /// reader.readNodeMap("label", labelMap); /// reader.skipNodeMap("description"); /// - /// reader.addNodeMap("color", colorMap); + /// reader.readNodeMap("color", colorMap); /// \endcode /// - /// With the \c addEdgeMap() member function you can give an edge map + /// With the \c readEdgeMap() member function you can give an edge map /// reading command similar to the NodeMaps. /// /// \code - /// reader.addEdgeMap("weight", weightMap); - /// reader.addEdgeMap("label", labelMap); + /// reader.readEdgeMap("weight", weightMap); + /// reader.readEdgeMap("label", labelMap); /// \endcode /// - /// With \c addNode() and \c addEdge() functions you can read labeled Nodes + /// With \c readNode() and \c readEdge() functions you can read labeled Nodes /// and Edges. /// /// \code - /// reader.addNode("source", sourceNode); - /// reader.addNode("target", targetNode); + /// reader.readNode("source", sourceNode); + /// reader.readNode("target", targetNode); /// - /// reader.addEdge("observed", edge); + /// reader.readEdge("observed", edge); /// \endcode /// /// After you give all read commands you must call the \c run() member @@ -285,8 +285,8 @@ /// /// Add a new node map reader command for the reader. template - GraphReader& addNodeMap(std::string name, Map& map) { - return addNodeMap, Map>(name, map); } @@ -294,7 +294,7 @@ /// /// Add a new node map reader command for the reader. template - GraphReader& addNodeMap(std::string name, Map& map, + GraphReader& readNodeMap(std::string name, Map& map, const Reader& reader = Reader()) { if (node_map_readers.find(name) != node_map_readers.end()) { ErrorMessage msg; @@ -326,8 +326,8 @@ /// /// Add a new edge map reader command for the reader. template - GraphReader& addEdgeMap(std::string name, Map& map) { - return addEdgeMap, Map>(name, map); } @@ -336,7 +336,7 @@ /// /// Add a new edge map reader command for the reader. template - GraphReader& addEdgeMap(std::string name, Map& map, + GraphReader& readEdgeMap(std::string name, Map& map, const Reader& reader = Reader()) { if (edge_map_readers.find(name) != edge_map_readers.end()) { ErrorMessage msg; @@ -367,7 +367,7 @@ /// \brief Add a new labeled node reader for the reader. /// /// Add a new labeled node reader for the reader. - GraphReader& addNode(std::string name, Node& node) { + GraphReader& readNode(std::string name, Node& node) { if (node_readers.find(name) != node_readers.end()) { ErrorMessage msg; msg << "Multiple read rule for node: " << name; @@ -380,7 +380,7 @@ /// \brief Add a new labeled edge reader for the reader. /// /// Add a new labeled edge reader for the reader. - GraphReader& addEdge(std::string name, Edge& edge) { + GraphReader& readEdge(std::string name, Edge& edge) { if (edge_readers.find(name) != edge_readers.end()) { ErrorMessage msg; msg << "Multiple read rule for edge: " << name; @@ -754,10 +754,10 @@ typename Graph::Node &s, typename Graph::Node &t, CostMap& cost) { GraphReader reader(is, g); - reader.addEdgeMap("capacity", capacity); - reader.addEdgeMap("cost", cost); - reader.addNode("source", s); - reader.addNode("target", t); + reader.readEdgeMap("capacity", capacity); + reader.readEdgeMap("cost", cost); + reader.readNode("source", s); + reader.readNode("target", t); reader.run(); } @@ -773,9 +773,9 @@ void readGraph(std::istream& is, Graph &g, CapacityMap& capacity, typename Graph::Node &s, typename Graph::Node &t) { GraphReader reader(is, g); - reader.addEdgeMap("capacity", capacity); - reader.addNode("source", s); - reader.addNode("target", t); + reader.readEdgeMap("capacity", capacity); + reader.readNode("source", s); + reader.readNode("target", t); reader.run(); } @@ -790,8 +790,8 @@ void readGraph(std::istream& is, Graph &g, CapacityMap& capacity, typename Graph::Node &s) { GraphReader reader(is, g); - reader.addEdgeMap("capacity", capacity); - reader.addNode("source", s); + reader.readEdgeMap("capacity", capacity); + reader.readNode("source", s); reader.run(); } @@ -804,7 +804,7 @@ template void readGraph(std::istream& is, Graph &g, CapacityMap& capacity) { GraphReader reader(is, g); - reader.addEdgeMap("capacity", capacity); + reader.readEdgeMap("capacity", capacity); reader.run(); } diff -r 2edd8cd06eaf -r f0c48d7fa73d src/lemon/graph_writer.h --- a/src/lemon/graph_writer.h Wed Apr 27 10:42:58 2005 +0000 +++ b/src/lemon/graph_writer.h Wed Apr 27 10:44:58 2005 +0000 @@ -168,41 +168,42 @@ /// GraphWriter writer(std::cout, graph); /// \endcode /// - /// The \c addNodeMap() function declares a \c NodeMap writing command in the - /// \c GraphWriter. You should give as parameter the name of the map and the - /// map object. The NodeMap writing command with name "id" should write a - /// unique map because it is regarded as ID map. + /// The \c writeNodeMap() function declares a \c NodeMap writing + /// command in the \c GraphWriter. You should give as parameter + /// the name of the map and the map object. The NodeMap writing + /// command with name "id" should write a unique map because it + /// is regarded as ID map. /// /// \code /// IdMap nodeIdMap; - /// writer.addNodeMap("id", nodeIdMap); + /// writer.writeNodeMap("id", nodeIdMap); /// - /// writer.addNodeMap("x-coord", xCoordMap); - /// writer.addNodeMap("y-coord", yCoordMap); - /// writer.addNodeMap("color", colorMap); + /// writer.writeNodeMap("x-coord", xCoordMap); + /// writer.writeNodeMap("y-coord", yCoordMap); + /// writer.writeNodeMap("color", colorMap); /// \endcode /// - /// With the \c addEdgeMap() member function you can give an edge map + /// With the \c writeEdgeMap() member function you can give an edge map /// writing command similar to the NodeMaps. /// /// \code /// DescriptorMap > /// edgeDescMap(graph); - /// writer.addEdgeMap("descriptor", edgeDescMap); + /// writer.writeEdgeMap("descriptor", edgeDescMap); /// - /// writer.addEdgeMap("weight", weightMap); - /// writer.addEdgeMap("label", labelMap); + /// writer.writeEdgeMap("weight", weightMap); + /// writer.writeEdgeMap("label", labelMap); /// \endcode /// - /// With \c addNode() and \c addEdge() functions you can point out Nodes and - /// Edges in the graph. By example, you can write out the source and target - /// of the graph. + /// With \c writeNode() and \c writeEdge() functions you can + /// point out Nodes and Edges in the graph. By example, you can + /// write out the source and target of the graph. /// /// \code - /// writer.addNode("source", sourceNode); - /// writer.addNode("target", targetNode); + /// writer.writeNode("source", sourceNode); + /// writer.writeNode("target", targetNode); /// - /// writer.addEdge("observed", edge); + /// writer.writeEdge("observed", edge); /// \endcode /// /// After you give all write commands you must call the \c run() member @@ -216,7 +217,7 @@ /// \see QuotedStringWriter /// \see IdMap /// \see DescriptorMap - /// \see \ref GraphReader + /// \see \ref GraphWriter /// \see \ref graph-io-page /// \author Balazs Dezso template @@ -262,8 +263,8 @@ /// /// Add a new node map writer command for the writer. template - GraphWriter& addNodeMap(std::string name, const Map& map) { - return addNodeMap, Map>(name, map); } @@ -271,7 +272,7 @@ /// /// Add a new node map writer command for the writer. template - GraphWriter& addNodeMap(std::string name, const Map& map, + GraphWriter& writeNodeMap(std::string name, const Map& map, const Writer& writer = Writer()) { node_map_writers.push_back( make_pair(name, new MapWriter(map, writer))); @@ -284,8 +285,8 @@ /// /// Add a new edge map writer command for the writer. template - GraphWriter& addEdgeMap(std::string name, const Map& map) { - return addEdgeMap, Map>(name, map); } @@ -294,7 +295,7 @@ /// /// Add a new edge map writer command for the writer. template - GraphWriter& addEdgeMap(std::string name, + GraphWriter& writeEdgeMap(std::string name, const Map& map, const Writer& writer = Writer()) { edge_map_writers.push_back(make_pair(name, new MapWriter(map, writer))); @@ -304,7 +305,7 @@ /// \brief Add a new labeled node writer for the writer. /// /// Add a new labeled node writer for the writer. - GraphWriter& addNode(std::string name, const Node& node) { + GraphWriter& writeNode(std::string name, const Node& node) { node_writers.push_back(make_pair(name, node)); return *this; } @@ -312,7 +313,7 @@ /// \brief Add a new labeled edge writer for the writer. /// /// Add a new labeled edge writer for the writer. - GraphWriter& addEdge(std::string name, const Edge& edge) { + GraphWriter& writeEdge(std::string name, const Edge& edge) { edge_writers.push_back(make_pair(name, edge)); return *this; } @@ -467,16 +468,16 @@ void writeGraph(std::ostream& os, const Graph &g, const CapacityMap& capacity, const typename Graph::Node &s, const typename Graph::Node &t, const CostMap& cost) { - GraphWriter reader(os, g); + GraphWriter writer(os, g); IdMap nodeIdMap(g); - reader.addNodeMap("id", nodeIdMap); + writer.writeNodeMap("id", nodeIdMap); IdMap edgeIdMap(g); - reader.addEdgeMap("id", edgeIdMap); - reader.addEdgeMap("capacity", capacity); - reader.addEdgeMap("cost", cost); - reader.addNode("source", s); - reader.addNode("target", t); - reader.run(); + writer.writeEdgeMap("id", edgeIdMap); + writer.writeEdgeMap("capacity", capacity); + writer.writeEdgeMap("cost", cost); + writer.writeNode("source", s); + writer.writeNode("target", t); + writer.run(); } /// \brief Write a graph to the output. @@ -491,15 +492,15 @@ void writeGraph(std::ostream& os, const Graph &g, const CapacityMap& capacity, const typename Graph::Node &s, const typename Graph::Node &t) { - GraphWriter reader(os, g); + GraphWriter writer(os, g); IdMap nodeIdMap(g); - reader.addNodeMap("id", nodeIdMap); + writer.writeNodeMap("id", nodeIdMap); IdMap edgeIdMap(g); - reader.addEdgeMap("id", edgeIdMap); - reader.addEdgeMap("capacity", capacity); - reader.addNode("source", s); - reader.addNode("target", t); - reader.run(); + writer.writeEdgeMap("id", edgeIdMap); + writer.writeEdgeMap("capacity", capacity); + writer.writeNode("source", s); + writer.writeNode("target", t); + writer.run(); } /// \brief Write a graph to the output. @@ -512,14 +513,14 @@ template void writeGraph(std::ostream& os, const Graph &g, const CapacityMap& capacity, const typename Graph::Node &s) { - GraphWriter reader(os, g); + GraphWriter writer(os, g); IdMap nodeIdMap(g); - reader.addNodeMap("id", nodeIdMap); + writer.writeNodeMap("id", nodeIdMap); IdMap edgeIdMap(g); - reader.addEdgeMap("id", edgeIdMap); - reader.addEdgeMap("capacity", capacity); - reader.addNode("source", s); - reader.run(); + writer.writeEdgeMap("id", edgeIdMap); + writer.writeEdgeMap("capacity", capacity); + writer.writeNode("source", s); + writer.run(); } /// \brief Write a graph to the output. @@ -531,13 +532,13 @@ template void writeGraph(std::ostream& os, const Graph &g, const CapacityMap& capacity) { - GraphWriter reader(os, g); + GraphWriter writer(os, g); IdMap nodeIdMap(g); - reader.addNodeMap("id", nodeIdMap); + writer.writeNodeMap("id", nodeIdMap); IdMap edgeIdMap(g); - reader.addEdgeMap("id", edgeIdMap); - reader.addEdgeMap("capacity", capacity); - reader.run(); + writer.writeEdgeMap("id", edgeIdMap); + writer.writeEdgeMap("capacity", capacity); + writer.run(); } /// \brief Write a graph to the output. @@ -547,12 +548,12 @@ /// \param g The graph. template void writeGraph(std::ostream& os, const Graph &g) { - GraphWriter reader(os, g); + GraphWriter writer(os, g); IdMap nodeIdMap(g); - reader.addNodeMap("id", nodeIdMap); + writer.writeNodeMap("id", nodeIdMap); IdMap edgeIdMap(g); - reader.addEdgeMap("id", edgeIdMap); - reader.run(); + writer.writeEdgeMap("id", edgeIdMap); + writer.run(); } /// @}