# HG changeset patch
# User athos
# Date 1119980795 0
# Node ID 3216612781375a06c274f984aacffacba142d15c
# Parent 5815b382421b82dfe07e2b555a16638de3a2a570
Some corrections to graph_io.dox (mainly language corrections). Improvements on quicktour.
diff -r 5815b382421b -r 321661278137 doc/graph_io.dox
--- a/doc/graph_io.dox Tue Jun 28 13:47:16 2005 +0000
+++ b/doc/graph_io.dox Tue Jun 28 17:46:35 2005 +0000
@@ -4,23 +4,26 @@
\page graph-io-page Graph Input-Output
-The standard graph IO makes possible to store graphs and additional maps
+The standard graph IO enables to store graphs and additional maps
in a flexible and efficient way.
\section format The general file format
-The graph file contains at most four section in the next order:
+The file contains at most four sections in the following order:
\li nodeset
\li edgeset
\li nodes
\li edges
-The nodeset section starts with the \c \@nodeset line.
-The next line contains the names of the maps separated by whitespaces.
-Each following line describes a node in the graph, it contains
-in the right order the values of the maps. The map named "id" should contain
-unique values because it regarded as ID-map.
+The nodeset section starts with the following line:
+
+\@nodeset
+
+The next line contains the names of the nodemaps, separated by whitespaces. Each
+following line describes a node in the graph: it contains the values of the
+maps in the right order. The map named "id" should contain unique values
+because it is regarded as an ID-map. For example:
\code
@nodeset
@@ -31,10 +34,14 @@
\endcode
The edgeset section is very similar to the nodeset section, it has
-same coloumn oriented structure. It starts with the line \c \@edgeset
-The next line contains the whitespace separated list of names of the map.
+the same coloumn oriented structure. It starts with the line
+
+\@edgeset
+
+The next line contains the whitespace separated list of names of the maps.
Each of the next lines describes one edge. The first two elements in the line
-are the ID of the source and target node as they occur in the ID node map.
+are the IDs of the source and target (or tail and head) node of the edge as they occur in the ID node
+map. You can also have an optional ID map on the edges for later reference.
\code
@edgeset
@@ -46,8 +53,11 @@
The next section contains labeled nodes (i.e. nodes having a special
label on them). The section starts with
-\c \@nodes. Each of the next lines contains a label for a node in the graph
-and then the ID described in the nodeset.
+
+ \@nodes
+
+Each of the next lines contains a label for a node in the graph
+and then the ID described in the nodeset section.
\code
@nodes
@@ -64,18 +74,20 @@
observed c
\endcode
-The file ends with the \c \@end line.
The file may contain empty lines and comment lines. The comment lines
start with an \c # character.
-\code
-@end
-\endcode
+The file ends with the
+
+ \@end
+
+line.
+
\section use Using graph input-output
-The graph input and output based on writing and reading commands. The user
-adds writing and reading commands for the reader or writer class, then
+The graph input and output is based on reading and writing commands. The user
+adds reading and writing commands to the reader or writer class, then he
calls the \c run() method that executes all the given commands.
\subsection write Writing a graph
@@ -90,8 +102,8 @@
\endcode
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
+\c GraphWriter. You should give a name of the map and the map
+object as parameters. The NodeMap writing command with name "id" should write a
unique map because it is regarded as ID map.
\see IdMap, DescriptorMap
@@ -109,6 +121,7 @@
writing command similar to the NodeMaps.
\see IdMap, DescriptorMap
+
\code
DescriptorMap > edgeDescMap(graph);
writer.writeEdgeMap("descriptor", edgeDescMap);
@@ -117,9 +130,9 @@
writer.writeEdgeMap("label", labelMap);
\endcode
-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.
+With \c writeNode() and \c writeEdge() functions you can designate Nodes and
+Edges in the graph. For example, you can write out the source and target node
+of a maximum flow instance.
\code
writer.writeNode("source", sourceNode);
@@ -129,7 +142,7 @@
\endcode
After you give all write commands you must call the \c run() member
-function, which execute all the writer commands.
+function, which executes all the writing commands.
\code
writer.run();
@@ -140,10 +153,10 @@
The given file format may contain several maps and labeled nodes or edges.
If you read a graph you need not read all the maps and items just those
that you need. The interface of the \c GraphReader is very similar to
-the GraphWriter but the reading method does not depend on the order the
+the GraphWriter but the reading method does not depend on the order of the
given commands.
-The reader object suppose that each not readed value does not contain
+The reader object assumes that each not readed value does not contain
whitespaces, therefore it has some extra possibilities to control how
it should skip the values when the string representation contains spaces.
@@ -152,11 +165,12 @@
\endcode
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
+If there is a map that you do not want to read from the file and there are
+whitespaces in the string represenation of the values then you should
call the \c skipNodeMap() template member function with proper parameters.
\see QuotedStringReader
+
\code
reader.readNodeMap("x-coord", xCoordMap);
reader.readNodeMap("y-coord", yCoordMap);
@@ -186,14 +200,14 @@
\endcode
After you give all read commands you must call the \c run() member
-function, which execute all the commands.
+function, which executes all the commands.
\code
reader.run();
\endcode
-\section types The background of the Reading and Writing
-The \c GraphReader should know how can read a Value from the given map.
+\section types The background of Reading and Writing
+The \c GraphReader should know how to read a Value from the given map.
By the default implementation the input operator reads a value from
the stream and the type of the readed value is the value type of the given map.
When the reader should skip a value in the stream, because you do not
diff -r 5815b382421b -r 321661278137 doc/quicktour.dox
--- a/doc/quicktour.dox Tue Jun 28 13:47:16 2005 +0000
+++ b/doc/quicktour.dox Tue Jun 28 17:46:35 2005 +0000
@@ -24,14 +24,29 @@
Some examples are the following (you will find links next to the code fragments that help to download full demo programs: save them on your computer and compile them according to the description in the page about \ref getsart How to start using LEMON):
-
-- First we give two examples that show how to instantiate a graph. The
-first one shows the methods that add nodes and edges, but one will
-usually use the second way which reads a graph from a stream (file).
-
-- The following code fragment shows how to fill a graph with data. It creates a complete graph on 4 nodes. The type Listgraph is one of the LEMON graph types: the typedefs in the beginning are for convenience and we will suppose them later as well.
- \code
- typedef ListGraph Graph;
+
- The first thing to discuss is the way one can create data structures
+like graphs and maps in a program using LEMON.
+//There are more graph types
+//implemented in LEMON and you can implement your own graph type just as well:
+//read more about this in the already mentioned page on \ref graphs "graphs".
+
+First we show how to add nodes and edges to a graph manually. We will also
+define a map on the edges of the graph. After this we show the way one can
+read a graph (and perhaps maps on it) from a stream (e.g. a file). Of course
+we also have routines that write a graph (and perhaps maps) to a stream
+(file): this will also be shown. LEMON supports the DIMACS file formats to
+store network optimization problems, but more importantly we also have our own
+file format that gives a more flexible way to store data related to network
+optimization.
+
+
- The following code fragment shows how to fill a graph with
+data. It creates a complete graph on 4 nodes. The type Listgraph is one of the
+LEMON graph types: the typedefs in the beginning are for convenience and we
+will suppose them later as well.
+
+\code
+
+ typedef ListGraph Graph;
typedef Graph::NodeIt NodeIt;
Graph g;
@@ -42,28 +57,95 @@
for (NodeIt i(g); i!=INVALID; ++i)
for (NodeIt j(g); j!=INVALID; ++j)
if (i != j) g.addEdge(i, j);
- \endcode
+
+\endcode
See the whole program in file \ref helloworld.cc.
If you want to read more on the LEMON graph structures and concepts, read the page about \ref graphs "graphs".
-
- The following code shows how to read a graph from a stream (e.g. a file). LEMON supports the DIMACS file format: it can read a graph instance from a file
-in that format (find the documentation of the DIMACS file format on the web).
+
- The following code shows how to read a graph from a stream (e.g. a file)
+in the DIMACS file format (find the documentation of the DIMACS file formats on the web).
+
\code
Graph g;
std::ifstream f("graph.dim");
readDimacs(f, g);
\endcode
-One can also store network (graph+capacity on the edges) instances and other things in DIMACS format and use these in LEMON: to see the details read the documentation of the \ref dimacs.h "Dimacs file format reader".
+
+One can also store network (graph+capacity on the edges) instances and other
+things (minimum cost flow instances etc.) in DIMACS format and use these in LEMON: to see the details read the
+documentation of the \ref dimacs.h "Dimacs file format reader". There you will
+also find the details about the output routines into files of the DIMACS
+format.
+
+
- We needed much greater flexibility than the DIMACS formats could give us,
+so we worked out our own file format. Instead of any explanation let us give a
+short example file in this format: read the detailed description of the LEMON
+graph file format and input-output routines \ref graph-io-page here.
+
+So here is a file describing a graph of 10 nodes (0 to 9), two nodemaps
+(called \c coordinates_x and \c coordinates_y), several edges, an edge map
+called \c length and two designated nodes (called \c source and \c target).
+
+\todo Maybe another example would be better here.
+
+\code
+@nodeset
+id coordinates_x coordinates_y
+9 447.907 578.328
+8 79.2573 909.464
+7 878.677 960.04
+6 11.5504 938.413
+5 327.398 815.035
+4 427.002 954.002
+3 148.549 753.748
+2 903.889 326.476
+1 408.248 577.327
+0 189.239 92.5316
+@edgeset
+ length
+2 3 901.074
+8 5 270.85
+6 9 601.553
+5 9 285.022
+9 4 408.091
+3 0 719.712
+7 5 612.836
+0 4 933.353
+5 0 778.871
+5 5 0
+7 1 664.049
+5 5 0
+0 9 560.464
+4 8 352.36
+4 9 399.625
+4 1 402.171
+1 2 591.688
+3 8 182.376
+4 5 180.254
+3 1 345.283
+5 4 184.511
+6 2 1112.45
+0 1 556.624
+@nodes
+source 1
+target 8
+@end
+\endcode
+
+Finally let us give a simple example that reads a graph from a file and writes
+it to another.
+
+\todo This is to be done!
- If you want to solve some transportation problems in a network then
you will want to find shortest paths between nodes of a graph. This is
usually solved using Dijkstra's algorithm. A utility
that solves this is the \ref lemon::Dijkstra "LEMON Dijkstra class".
-The following code is a simple program using the \ref lemon::Dijkstra "LEMON
-Dijkstra class" and it also shows how to define a map on the edges (the length
+The following code is a simple program using the
+\ref lemon::Dijkstra "LEMON Dijkstra class" and it also shows how to define a map on the edges (the length
function):
\code