[Lemon-commits] [lemon_svn] deba: r1851 - in hugo/trunk: doc src/demo src/lemon
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:48:12 CET 2006
Author: deba
Date: Wed Apr 27 12:44:58 2005
New Revision: 1851
Modified:
hugo/trunk/doc/graph_io.dox
hugo/trunk/src/demo/lp_maxflow_demo.cc
hugo/trunk/src/demo/min_route.cc
hugo/trunk/src/lemon/graph_reader.h
hugo/trunk/src/lemon/graph_writer.h
Log:
Modifying the interface.
add -> read, write
Modified: hugo/trunk/doc/graph_io.dox
==============================================================================
--- hugo/trunk/doc/graph_io.dox (original)
+++ hugo/trunk/doc/graph_io.dox Wed Apr 27 12:44:58 2005
@@ -89,7 +89,7 @@
GraphWriter<ListGraph> 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<ListGraph, Node> 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<ListGraph, Edge, ListGraph::EdgeMap<int> > 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<ListGraph> 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<QuotedStringReader>("label", labelMap);
+reader.readNodeMap<QuotedStringReader>("label", labelMap);
reader.skipNodeMap<QuotedStringReader>("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<LengthReader>("strings", lengthMap);
+reader.readNodeMap<LengthReader>("strings", lengthMap);
\endcode
The global functionality of the reader class can be changed by giving a
Modified: hugo/trunk/src/demo/lp_maxflow_demo.cc
==============================================================================
--- hugo/trunk/src/demo/lp_maxflow_demo.cc (original)
+++ hugo/trunk/src/demo/lp_maxflow_demo.cc Wed Apr 27 12:44:58 2005
@@ -75,8 +75,8 @@
ListGraph::EdgeMap<double> cap(g);
GraphReader<ListGraph> 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);
Modified: hugo/trunk/src/demo/min_route.cc
==============================================================================
--- hugo/trunk/src/demo/min_route.cc (original)
+++ hugo/trunk/src/demo/min_route.cc Wed Apr 27 12:44:58 2005
@@ -69,16 +69,16 @@
CoordMap coord(graph);
XMap<CoordMap> xcoord = xMap(coord);
- reader.addNodeMap("coordinates_x", xcoord);
+ reader.readNodeMap("coordinates_x", xcoord);
YMap<CoordMap> 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();
Modified: hugo/trunk/src/lemon/graph_reader.h
==============================================================================
--- hugo/trunk/src/lemon/graph_reader.h (original)
+++ hugo/trunk/src/lemon/graph_reader.h Wed Apr 27 12:44:58 2005
@@ -200,38 +200,38 @@
/// GraphReader<ListGraph> 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<QuotedStringReader>("label", labelMap);
+ /// reader.readNodeMap<QuotedStringReader>("label", labelMap);
/// reader.skipNodeMap<QuotedStringReader>("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 <typename Map>
- GraphReader& addNodeMap(std::string name, Map& map) {
- return addNodeMap<typename ReaderTraits::template
+ GraphReader& readNodeMap(std::string name, Map& map) {
+ return readNodeMap<typename ReaderTraits::template
Reader<typename Map::Value>, Map>(name, map);
}
@@ -294,7 +294,7 @@
///
/// Add a new node map reader command for the reader.
template <typename Reader, typename Map>
- 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 <typename Map>
- GraphReader& addEdgeMap(std::string name, Map& map) {
- return addEdgeMap<typename ReaderTraits::template
+ GraphReader& readEdgeMap(std::string name, Map& map) {
+ return readEdgeMap<typename ReaderTraits::template
Reader<typename Map::Value>, Map>(name, map);
}
@@ -336,7 +336,7 @@
///
/// Add a new edge map reader command for the reader.
template <typename Reader, typename Map>
- 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<Graph> 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<Graph> 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<Graph> 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<typename Graph, typename CapacityMap>
void readGraph(std::istream& is, Graph &g, CapacityMap& capacity) {
GraphReader<Graph> reader(is, g);
- reader.addEdgeMap("capacity", capacity);
+ reader.readEdgeMap("capacity", capacity);
reader.run();
}
Modified: hugo/trunk/src/lemon/graph_writer.h
==============================================================================
--- hugo/trunk/src/lemon/graph_writer.h (original)
+++ hugo/trunk/src/lemon/graph_writer.h Wed Apr 27 12:44:58 2005
@@ -168,41 +168,42 @@
/// GraphWriter<ListGraph> 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<ListGraph, Node> 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<ListGraph, Edge, ListGraph::EdgeMap<int> >
/// 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 <typename _Graph, typename _WriterTraits = DefaultWriterTraits>
@@ -262,8 +263,8 @@
///
/// Add a new node map writer command for the writer.
template <typename Map>
- GraphWriter& addNodeMap(std::string name, const Map& map) {
- return addNodeMap<typename WriterTraits::template Writer<
+ GraphWriter& writeNodeMap(std::string name, const Map& map) {
+ return writeNodeMap<typename WriterTraits::template Writer<
typename Map::Value>, Map>(name, map);
}
@@ -271,7 +272,7 @@
///
/// Add a new node map writer command for the writer.
template <typename Writer, typename Map>
- 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<Node, Map, Writer>(map, writer)));
@@ -284,8 +285,8 @@
///
/// Add a new edge map writer command for the writer.
template <typename Map>
- GraphWriter& addEdgeMap(std::string name, const Map& map) {
- return addEdgeMap<typename WriterTraits::template Writer<
+ GraphWriter& writeEdgeMap(std::string name, const Map& map) {
+ return writeEdgeMap<typename WriterTraits::template Writer<
typename Map::Value>, Map>(name, map);
}
@@ -294,7 +295,7 @@
///
/// Add a new edge map writer command for the writer.
template <typename Writer, typename Map>
- 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<Edge, Map, Writer>(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<Graph> reader(os, g);
+ GraphWriter<Graph> writer(os, g);
IdMap<Graph, typename Graph::Node> nodeIdMap(g);
- reader.addNodeMap("id", nodeIdMap);
+ writer.writeNodeMap("id", nodeIdMap);
IdMap<Graph, typename Graph::Edge> 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<Graph> reader(os, g);
+ GraphWriter<Graph> writer(os, g);
IdMap<Graph, typename Graph::Node> nodeIdMap(g);
- reader.addNodeMap("id", nodeIdMap);
+ writer.writeNodeMap("id", nodeIdMap);
IdMap<Graph, typename Graph::Edge> 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<typename Graph, typename CapacityMap>
void writeGraph(std::ostream& os, const Graph &g,
const CapacityMap& capacity, const typename Graph::Node &s) {
- GraphWriter<Graph> reader(os, g);
+ GraphWriter<Graph> writer(os, g);
IdMap<Graph, typename Graph::Node> nodeIdMap(g);
- reader.addNodeMap("id", nodeIdMap);
+ writer.writeNodeMap("id", nodeIdMap);
IdMap<Graph, typename Graph::Edge> 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<typename Graph, typename CapacityMap>
void writeGraph(std::ostream& os, const Graph &g,
const CapacityMap& capacity) {
- GraphWriter<Graph> reader(os, g);
+ GraphWriter<Graph> writer(os, g);
IdMap<Graph, typename Graph::Node> nodeIdMap(g);
- reader.addNodeMap("id", nodeIdMap);
+ writer.writeNodeMap("id", nodeIdMap);
IdMap<Graph, typename Graph::Edge> 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<typename Graph>
void writeGraph(std::ostream& os, const Graph &g) {
- GraphWriter<Graph> reader(os, g);
+ GraphWriter<Graph> writer(os, g);
IdMap<Graph, typename Graph::Node> nodeIdMap(g);
- reader.addNodeMap("id", nodeIdMap);
+ writer.writeNodeMap("id", nodeIdMap);
IdMap<Graph, typename Graph::Edge> edgeIdMap(g);
- reader.addEdgeMap("id", edgeIdMap);
- reader.run();
+ writer.writeEdgeMap("id", edgeIdMap);
+ writer.run();
}
/// @}
More information about the Lemon-commits
mailing list