Changeset 1522:321661278137 in lemon-0.x for doc
- Timestamp:
- 06/28/05 19:46:35 (19 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2008
- Location:
- doc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/graph_io.dox
r1394 r1522 5 5 \page graph-io-page Graph Input-Output 6 6 7 The standard graph IO makes possibleto store graphs and additional maps7 The standard graph IO enables to store graphs and additional maps 8 8 in a flexible and efficient way. 9 9 10 10 \section format The general file format 11 11 12 The graph file contains at most four section in the nextorder:12 The file contains at most four sections in the following order: 13 13 14 14 \li nodeset … … 17 17 \li edges 18 18 19 The nodeset section starts with the \c \@nodeset line. 20 The next line contains the names of the maps separated by whitespaces. 21 Each following line describes a node in the graph, it contains 22 in the right order the values of the maps. The map named "id" should contain 23 unique values because it regarded as ID-map. 19 The nodeset section starts with the following line: 20 21 <tt>\@nodeset</tt> 22 23 The next line contains the names of the nodemaps, separated by whitespaces. Each 24 following line describes a node in the graph: it contains the values of the 25 maps in the right order. The map named "id" should contain unique values 26 because it is regarded as an ID-map. For example: 24 27 25 28 \code … … 32 35 33 36 The edgeset section is very similar to the nodeset section, it has 34 same coloumn oriented structure. It starts with the line \c \@edgeset 35 The next line contains the whitespace separated list of names of the map. 37 the same coloumn oriented structure. It starts with the line 38 39 <tt>\@edgeset</tt> 40 41 The next line contains the whitespace separated list of names of the maps. 36 42 Each of the next lines describes one edge. The first two elements in the line 37 are the ID of the source and target node as they occur in the ID node map. 43 are the IDs of the source and target (or tail and head) node of the edge as they occur in the ID node 44 map. You can also have an optional ID map on the edges for later reference. 38 45 39 46 \code … … 47 54 The next section contains <em>labeled nodes</em> (i.e. nodes having a special 48 55 label on them). The section starts with 49 \c \@nodes. Each of the next lines contains a label for a node in the graph 50 and then the ID described in the nodeset. 56 57 <tt> \@nodes </tt> 58 59 Each of the next lines contains a label for a node in the graph 60 and then the ID described in the nodeset section. 51 61 52 62 \code … … 65 75 \endcode 66 76 67 The file ends with the \c \@end line.68 77 69 78 The file may contain empty lines and comment lines. The comment lines 70 79 start with an \c # character. 71 80 72 \code 73 @end 74 \endcode 81 The file ends with the 82 83 <tt> \@end </tt> 84 85 line. 86 75 87 76 88 \section use Using graph input-output 77 The graph input and output based on writing and readingcommands. The user78 adds writing and reading commands for the reader or writer class, then89 The graph input and output is based on reading and writing commands. The user 90 adds reading and writing commands to the reader or writer class, then he 79 91 calls the \c run() method that executes all the given commands. 80 92 … … 91 103 92 104 The \c writeNodeMap() function declares a \c NodeMap writing command in the 93 \c GraphWriter. You should give a s parameter thename of the map and the map94 object . The NodeMap writing command with name "id" should write a105 \c GraphWriter. You should give a name of the map and the map 106 object as parameters. The NodeMap writing command with name "id" should write a 95 107 unique map because it is regarded as ID map. 96 108 … … 110 122 111 123 \see IdMap, DescriptorMap 124 112 125 \code 113 126 DescriptorMap<ListGraph, Edge, ListGraph::EdgeMap<int> > edgeDescMap(graph); … … 118 131 \endcode 119 132 120 With \c writeNode() and \c writeEdge() functions you can point outNodes and121 Edges in the graph. By example, you can write out the source and target122 of the graph.133 With \c writeNode() and \c writeEdge() functions you can designate Nodes and 134 Edges in the graph. For example, you can write out the source and target node 135 of a maximum flow instance. 123 136 124 137 \code … … 130 143 131 144 After you give all write commands you must call the \c run() member 132 function, which execute all the writercommands.145 function, which executes all the writing commands. 133 146 134 147 \code … … 141 154 If you read a graph you need not read all the maps and items just those 142 155 that you need. The interface of the \c GraphReader is very similar to 143 the GraphWriter but the reading method does not depend on the order the156 the GraphWriter but the reading method does not depend on the order of the 144 157 given commands. 145 158 146 The reader object supposethat each not readed value does not contain159 The reader object assumes that each not readed value does not contain 147 160 whitespaces, therefore it has some extra possibilities to control how 148 161 it should skip the values when the string representation contains spaces. … … 153 166 154 167 The \c readNodeMap() function reads a map from the \c \@nodeset section. 155 If there is a map that you do not want to read from the file and there is156 whitespace in the string represenation of the values then you should168 If there is a map that you do not want to read from the file and there are 169 whitespaces in the string represenation of the values then you should 157 170 call the \c skipNodeMap() template member function with proper parameters. 158 171 159 172 \see QuotedStringReader 173 160 174 \code 161 175 reader.readNodeMap("x-coord", xCoordMap); … … 187 201 188 202 After you give all read commands you must call the \c run() member 189 function, which execute all the commands.203 function, which executes all the commands. 190 204 191 205 \code … … 193 207 \endcode 194 208 195 \section types The background of theReading and Writing196 The \c GraphReader should know how canread a Value from the given map.209 \section types The background of Reading and Writing 210 The \c GraphReader should know how to read a Value from the given map. 197 211 By the default implementation the input operator reads a value from 198 212 the stream and the type of the readed value is the value type of the given map. -
doc/quicktour.dox
r1521 r1522 25 25 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): 26 26 27 <ul> 28 <li> First we give two examples that show how to instantiate a graph. The 29 first one shows the methods that add nodes and edges, but one will 30 usually use the second way which reads a graph from a stream (file). 31 <ol> 32 <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. 33 \code 34 typedef ListGraph Graph; 27 <ul> <li> The first thing to discuss is the way one can create data structures 28 like graphs and maps in a program using LEMON. 29 //There are more graph types 30 //implemented in LEMON and you can implement your own graph type just as well: 31 //read more about this in the already mentioned page on \ref graphs "graphs". 32 33 First we show how to add nodes and edges to a graph manually. We will also 34 define a map on the edges of the graph. After this we show the way one can 35 read a graph (and perhaps maps on it) from a stream (e.g. a file). Of course 36 we also have routines that write a graph (and perhaps maps) to a stream 37 (file): this will also be shown. LEMON supports the DIMACS file formats to 38 store network optimization problems, but more importantly we also have our own 39 file format that gives a more flexible way to store data related to network 40 optimization. 41 42 <ol> <li>The following code fragment shows how to fill a graph with 43 data. It creates a complete graph on 4 nodes. The type Listgraph is one of the 44 LEMON graph types: the typedefs in the beginning are for convenience and we 45 will suppose them later as well. 46 47 \code 48 49 typedef ListGraph Graph; 35 50 typedef Graph::NodeIt NodeIt; 36 51 … … 43 58 for (NodeIt j(g); j!=INVALID; ++j) 44 59 if (i != j) g.addEdge(i, j); 45 \endcode 60 61 \endcode 46 62 47 63 See the whole program in file \ref helloworld.cc. … … 49 65 If you want to read more on the LEMON graph structures and concepts, read the page about \ref graphs "graphs". 50 66 51 <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 52 in that format (find the documentation of the DIMACS file format on the web). 67 <li> The following code shows how to read a graph from a stream (e.g. a file) 68 in the DIMACS file format (find the documentation of the DIMACS file formats on the web). 69 53 70 \code 54 71 Graph g; … … 56 73 readDimacs(f, g); 57 74 \endcode 58 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". 75 76 One can also store network (graph+capacity on the edges) instances and other 77 things (minimum cost flow instances etc.) in DIMACS format and use these in LEMON: to see the details read the 78 documentation of the \ref dimacs.h "Dimacs file format reader". There you will 79 also find the details about the output routines into files of the DIMACS 80 format. 81 82 <li>We needed much greater flexibility than the DIMACS formats could give us, 83 so we worked out our own file format. Instead of any explanation let us give a 84 short example file in this format: read the detailed description of the LEMON 85 graph file format and input-output routines \ref graph-io-page here. 86 87 So here is a file describing a graph of 10 nodes (0 to 9), two nodemaps 88 (called \c coordinates_x and \c coordinates_y), several edges, an edge map 89 called \c length and two designated nodes (called \c source and \c target). 90 91 \todo Maybe another example would be better here. 92 93 \code 94 @nodeset 95 id coordinates_x coordinates_y 96 9 447.907 578.328 97 8 79.2573 909.464 98 7 878.677 960.04 99 6 11.5504 938.413 100 5 327.398 815.035 101 4 427.002 954.002 102 3 148.549 753.748 103 2 903.889 326.476 104 1 408.248 577.327 105 0 189.239 92.5316 106 @edgeset 107 length 108 2 3 901.074 109 8 5 270.85 110 6 9 601.553 111 5 9 285.022 112 9 4 408.091 113 3 0 719.712 114 7 5 612.836 115 0 4 933.353 116 5 0 778.871 117 5 5 0 118 7 1 664.049 119 5 5 0 120 0 9 560.464 121 4 8 352.36 122 4 9 399.625 123 4 1 402.171 124 1 2 591.688 125 3 8 182.376 126 4 5 180.254 127 3 1 345.283 128 5 4 184.511 129 6 2 1112.45 130 0 1 556.624 131 @nodes 132 source 1 133 target 8 134 @end 135 \endcode 136 137 Finally let us give a simple example that reads a graph from a file and writes 138 it to another. 139 140 \todo This is to be done! 59 141 60 142 </ol> … … 63 145 usually solved using Dijkstra's algorithm. A utility 64 146 that solves this is the \ref lemon::Dijkstra "LEMON Dijkstra class". 65 The following code is a simple program using the \ref lemon::Dijkstra "LEMON66 Dijkstra class" and it also shows how to define a map on the edges (the length147 The following code is a simple program using the 148 \ref lemon::Dijkstra "LEMON Dijkstra class" and it also shows how to define a map on the edges (the length 67 149 function): 68 150
Note: See TracChangeset
for help on using the changeset viewer.