Some corrections to graph_io.dox (mainly language corrections). Improvements on quicktour.
1.1 --- a/doc/graph_io.dox Tue Jun 28 13:47:16 2005 +0000
1.2 +++ b/doc/graph_io.dox Tue Jun 28 17:46:35 2005 +0000
1.3 @@ -4,23 +4,26 @@
1.4
1.5 \page graph-io-page Graph Input-Output
1.6
1.7 -The standard graph IO makes possible to store graphs and additional maps
1.8 +The standard graph IO enables to store graphs and additional maps
1.9 in a flexible and efficient way.
1.10
1.11 \section format The general file format
1.12
1.13 -The graph file contains at most four section in the next order:
1.14 +The file contains at most four sections in the following order:
1.15
1.16 \li nodeset
1.17 \li edgeset
1.18 \li nodes
1.19 \li edges
1.20
1.21 -The nodeset section starts with the \c \@nodeset line.
1.22 -The next line contains the names of the maps separated by whitespaces.
1.23 -Each following line describes a node in the graph, it contains
1.24 -in the right order the values of the maps. The map named "id" should contain
1.25 -unique values because it regarded as ID-map.
1.26 +The nodeset section starts with the following line:
1.27 +
1.28 +<tt>\@nodeset</tt>
1.29 +
1.30 +The next line contains the names of the nodemaps, separated by whitespaces. Each
1.31 +following line describes a node in the graph: it contains the values of the
1.32 +maps in the right order. The map named "id" should contain unique values
1.33 +because it is regarded as an ID-map. For example:
1.34
1.35 \code
1.36 @nodeset
1.37 @@ -31,10 +34,14 @@
1.38 \endcode
1.39
1.40 The edgeset section is very similar to the nodeset section, it has
1.41 -same coloumn oriented structure. It starts with the line \c \@edgeset
1.42 -The next line contains the whitespace separated list of names of the map.
1.43 +the same coloumn oriented structure. It starts with the line
1.44 +
1.45 +<tt>\@edgeset</tt>
1.46 +
1.47 +The next line contains the whitespace separated list of names of the maps.
1.48 Each of the next lines describes one edge. The first two elements in the line
1.49 -are the ID of the source and target node as they occur in the ID node map.
1.50 +are the IDs of the source and target (or tail and head) node of the edge as they occur in the ID node
1.51 +map. You can also have an optional ID map on the edges for later reference.
1.52
1.53 \code
1.54 @edgeset
1.55 @@ -46,8 +53,11 @@
1.56
1.57 The next section contains <em>labeled nodes</em> (i.e. nodes having a special
1.58 label on them). The section starts with
1.59 -\c \@nodes. Each of the next lines contains a label for a node in the graph
1.60 -and then the ID described in the nodeset.
1.61 +
1.62 +<tt> \@nodes </tt>
1.63 +
1.64 +Each of the next lines contains a label for a node in the graph
1.65 +and then the ID described in the nodeset section.
1.66
1.67 \code
1.68 @nodes
1.69 @@ -64,18 +74,20 @@
1.70 observed c
1.71 \endcode
1.72
1.73 -The file ends with the \c \@end line.
1.74
1.75 The file may contain empty lines and comment lines. The comment lines
1.76 start with an \c # character.
1.77
1.78 -\code
1.79 -@end
1.80 -\endcode
1.81 +The file ends with the
1.82 +
1.83 +<tt> \@end </tt>
1.84 +
1.85 +line.
1.86 +
1.87
1.88 \section use Using graph input-output
1.89 -The graph input and output based on writing and reading commands. The user
1.90 -adds writing and reading commands for the reader or writer class, then
1.91 +The graph input and output is based on reading and writing commands. The user
1.92 +adds reading and writing commands to the reader or writer class, then he
1.93 calls the \c run() method that executes all the given commands.
1.94
1.95 \subsection write Writing a graph
1.96 @@ -90,8 +102,8 @@
1.97 \endcode
1.98
1.99 The \c writeNodeMap() function declares a \c NodeMap writing command in the
1.100 -\c GraphWriter. You should give as parameter the name of the map and the map
1.101 -object. The NodeMap writing command with name "id" should write a
1.102 +\c GraphWriter. You should give a name of the map and the map
1.103 +object as parameters. The NodeMap writing command with name "id" should write a
1.104 unique map because it is regarded as ID map.
1.105
1.106 \see IdMap, DescriptorMap
1.107 @@ -109,6 +121,7 @@
1.108 writing command similar to the NodeMaps.
1.109
1.110 \see IdMap, DescriptorMap
1.111 +
1.112 \code
1.113 DescriptorMap<ListGraph, Edge, ListGraph::EdgeMap<int> > edgeDescMap(graph);
1.114 writer.writeEdgeMap("descriptor", edgeDescMap);
1.115 @@ -117,9 +130,9 @@
1.116 writer.writeEdgeMap("label", labelMap);
1.117 \endcode
1.118
1.119 -With \c writeNode() and \c writeEdge() functions you can point out Nodes and
1.120 -Edges in the graph. By example, you can write out the source and target
1.121 -of the graph.
1.122 +With \c writeNode() and \c writeEdge() functions you can designate Nodes and
1.123 +Edges in the graph. For example, you can write out the source and target node
1.124 +of a maximum flow instance.
1.125
1.126 \code
1.127 writer.writeNode("source", sourceNode);
1.128 @@ -129,7 +142,7 @@
1.129 \endcode
1.130
1.131 After you give all write commands you must call the \c run() member
1.132 -function, which execute all the writer commands.
1.133 +function, which executes all the writing commands.
1.134
1.135 \code
1.136 writer.run();
1.137 @@ -140,10 +153,10 @@
1.138 The given file format may contain several maps and labeled nodes or edges.
1.139 If you read a graph you need not read all the maps and items just those
1.140 that you need. The interface of the \c GraphReader is very similar to
1.141 -the GraphWriter but the reading method does not depend on the order the
1.142 +the GraphWriter but the reading method does not depend on the order of the
1.143 given commands.
1.144
1.145 -The reader object suppose that each not readed value does not contain
1.146 +The reader object assumes that each not readed value does not contain
1.147 whitespaces, therefore it has some extra possibilities to control how
1.148 it should skip the values when the string representation contains spaces.
1.149
1.150 @@ -152,11 +165,12 @@
1.151 \endcode
1.152
1.153 The \c readNodeMap() function reads a map from the \c \@nodeset section.
1.154 -If there is a map that you do not want to read from the file and there is
1.155 -whitespace in the string represenation of the values then you should
1.156 +If there is a map that you do not want to read from the file and there are
1.157 +whitespaces in the string represenation of the values then you should
1.158 call the \c skipNodeMap() template member function with proper parameters.
1.159
1.160 \see QuotedStringReader
1.161 +
1.162 \code
1.163 reader.readNodeMap("x-coord", xCoordMap);
1.164 reader.readNodeMap("y-coord", yCoordMap);
1.165 @@ -186,14 +200,14 @@
1.166 \endcode
1.167
1.168 After you give all read commands you must call the \c run() member
1.169 -function, which execute all the commands.
1.170 +function, which executes all the commands.
1.171
1.172 \code
1.173 reader.run();
1.174 \endcode
1.175
1.176 -\section types The background of the Reading and Writing
1.177 -The \c GraphReader should know how can read a Value from the given map.
1.178 +\section types The background of Reading and Writing
1.179 +The \c GraphReader should know how to read a Value from the given map.
1.180 By the default implementation the input operator reads a value from
1.181 the stream and the type of the readed value is the value type of the given map.
1.182 When the reader should skip a value in the stream, because you do not
2.1 --- a/doc/quicktour.dox Tue Jun 28 13:47:16 2005 +0000
2.2 +++ b/doc/quicktour.dox Tue Jun 28 17:46:35 2005 +0000
2.3 @@ -24,14 +24,29 @@
2.4
2.5 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):
2.6
2.7 -<ul>
2.8 -<li> First we give two examples that show how to instantiate a graph. The
2.9 -first one shows the methods that add nodes and edges, but one will
2.10 -usually use the second way which reads a graph from a stream (file).
2.11 -<ol>
2.12 -<li>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.
2.13 - \code
2.14 - typedef ListGraph Graph;
2.15 +<ul> <li> The first thing to discuss is the way one can create data structures
2.16 +like graphs and maps in a program using LEMON.
2.17 +//There are more graph types
2.18 +//implemented in LEMON and you can implement your own graph type just as well:
2.19 +//read more about this in the already mentioned page on \ref graphs "graphs".
2.20 +
2.21 +First we show how to add nodes and edges to a graph manually. We will also
2.22 +define a map on the edges of the graph. After this we show the way one can
2.23 +read a graph (and perhaps maps on it) from a stream (e.g. a file). Of course
2.24 +we also have routines that write a graph (and perhaps maps) to a stream
2.25 +(file): this will also be shown. LEMON supports the DIMACS file formats to
2.26 +store network optimization problems, but more importantly we also have our own
2.27 +file format that gives a more flexible way to store data related to network
2.28 +optimization.
2.29 +
2.30 +<ol> <li>The following code fragment shows how to fill a graph with
2.31 +data. It creates a complete graph on 4 nodes. The type Listgraph is one of the
2.32 +LEMON graph types: the typedefs in the beginning are for convenience and we
2.33 +will suppose them later as well.
2.34 +
2.35 +\code
2.36 +
2.37 + typedef ListGraph Graph;
2.38 typedef Graph::NodeIt NodeIt;
2.39
2.40 Graph g;
2.41 @@ -42,28 +57,95 @@
2.42 for (NodeIt i(g); i!=INVALID; ++i)
2.43 for (NodeIt j(g); j!=INVALID; ++j)
2.44 if (i != j) g.addEdge(i, j);
2.45 - \endcode
2.46 +
2.47 +\endcode
2.48
2.49 See the whole program in file \ref helloworld.cc.
2.50
2.51 If you want to read more on the LEMON graph structures and concepts, read the page about \ref graphs "graphs".
2.52
2.53 -<li> 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
2.54 -in that format (find the documentation of the DIMACS file format on the web).
2.55 +<li> The following code shows how to read a graph from a stream (e.g. a file)
2.56 +in the DIMACS file format (find the documentation of the DIMACS file formats on the web).
2.57 +
2.58 \code
2.59 Graph g;
2.60 std::ifstream f("graph.dim");
2.61 readDimacs(f, g);
2.62 \endcode
2.63 -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".
2.64 +
2.65 +One can also store network (graph+capacity on the edges) instances and other
2.66 +things (minimum cost flow instances etc.) in DIMACS format and use these in LEMON: to see the details read the
2.67 +documentation of the \ref dimacs.h "Dimacs file format reader". There you will
2.68 +also find the details about the output routines into files of the DIMACS
2.69 +format.
2.70 +
2.71 +<li>We needed much greater flexibility than the DIMACS formats could give us,
2.72 +so we worked out our own file format. Instead of any explanation let us give a
2.73 +short example file in this format: read the detailed description of the LEMON
2.74 +graph file format and input-output routines \ref graph-io-page here.
2.75 +
2.76 +So here is a file describing a graph of 10 nodes (0 to 9), two nodemaps
2.77 +(called \c coordinates_x and \c coordinates_y), several edges, an edge map
2.78 +called \c length and two designated nodes (called \c source and \c target).
2.79 +
2.80 +\todo Maybe another example would be better here.
2.81 +
2.82 +\code
2.83 +@nodeset
2.84 +id coordinates_x coordinates_y
2.85 +9 447.907 578.328
2.86 +8 79.2573 909.464
2.87 +7 878.677 960.04
2.88 +6 11.5504 938.413
2.89 +5 327.398 815.035
2.90 +4 427.002 954.002
2.91 +3 148.549 753.748
2.92 +2 903.889 326.476
2.93 +1 408.248 577.327
2.94 +0 189.239 92.5316
2.95 +@edgeset
2.96 + length
2.97 +2 3 901.074
2.98 +8 5 270.85
2.99 +6 9 601.553
2.100 +5 9 285.022
2.101 +9 4 408.091
2.102 +3 0 719.712
2.103 +7 5 612.836
2.104 +0 4 933.353
2.105 +5 0 778.871
2.106 +5 5 0
2.107 +7 1 664.049
2.108 +5 5 0
2.109 +0 9 560.464
2.110 +4 8 352.36
2.111 +4 9 399.625
2.112 +4 1 402.171
2.113 +1 2 591.688
2.114 +3 8 182.376
2.115 +4 5 180.254
2.116 +3 1 345.283
2.117 +5 4 184.511
2.118 +6 2 1112.45
2.119 +0 1 556.624
2.120 +@nodes
2.121 +source 1
2.122 +target 8
2.123 +@end
2.124 +\endcode
2.125 +
2.126 +Finally let us give a simple example that reads a graph from a file and writes
2.127 +it to another.
2.128 +
2.129 +\todo This is to be done!
2.130
2.131 </ol>
2.132 <li> If you want to solve some transportation problems in a network then
2.133 you will want to find shortest paths between nodes of a graph. This is
2.134 usually solved using Dijkstra's algorithm. A utility
2.135 that solves this is the \ref lemon::Dijkstra "LEMON Dijkstra class".
2.136 -The following code is a simple program using the \ref lemon::Dijkstra "LEMON
2.137 -Dijkstra class" and it also shows how to define a map on the edges (the length
2.138 +The following code is a simple program using the
2.139 +\ref lemon::Dijkstra "LEMON Dijkstra class" and it also shows how to define a map on the edges (the length
2.140 function):
2.141
2.142 \code