COIN-OR::LEMON - Graph Library

Changeset 1522:321661278137 in lemon-0.x for doc/quicktour.dox


Ignore:
Timestamp:
06/28/05 19:46:35 (14 years ago)
Author:
athos
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2008
Message:

Some corrections to graph_io.dox (mainly language corrections). Improvements on quicktour.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/quicktour.dox

    r1521 r1522  
    2525Some 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):
    2626
    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
     28like 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
     33First we show how to add nodes and edges to a graph manually. We will also
     34define a map on the edges of the graph. After this we show the way one can
     35read a graph (and perhaps maps on it) from a stream (e.g. a file). Of course
     36we 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
     38store network optimization problems, but more importantly we also have our own
     39file format that gives a more flexible way to store data related to network
     40optimization.
     41
     42<ol> <li>The following code fragment shows how to fill a graph with
     43data. It creates a complete graph on 4 nodes. The type Listgraph is one of the
     44LEMON graph types: the typedefs in the beginning are for convenience and we
     45will suppose them later as well. 
     46
     47\code
     48
     49  typedef ListGraph Graph;
    3550  typedef Graph::NodeIt NodeIt;
    3651
     
    4358    for (NodeIt j(g); j!=INVALID; ++j)
    4459      if (i != j) g.addEdge(i, j);
    45  \endcode
     60
     61\endcode
    4662
    4763See the whole program in file \ref helloworld.cc.
     
    4965    If you want to read more on the LEMON graph structures and concepts, read the page about \ref graphs "graphs".
    5066
    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)
     68in the DIMACS file format (find the documentation of the DIMACS file formats on the web).
     69
    5370\code
    5471Graph g;
     
    5673readDimacs(f, g);
    5774\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
     76One can also store network (graph+capacity on the edges) instances and other
     77things (minimum cost flow instances etc.) in DIMACS format and use these in LEMON: to see the details read the
     78documentation of the \ref dimacs.h "Dimacs file format reader". There you will
     79also find the details about the output routines into files of the DIMACS
     80format.
     81
     82<li>We needed much greater flexibility than the DIMACS formats could give us,
     83so we worked out our own file format. Instead of any explanation let us give a
     84short example file in this format: read the detailed description of the LEMON
     85graph file format and input-output routines \ref graph-io-page here.
     86
     87So 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
     89called \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
     95id      coordinates_x   coordinates_y   
     969       447.907 578.328
     978       79.2573 909.464
     987       878.677 960.04 
     996       11.5504 938.413
     1005       327.398 815.035
     1014       427.002 954.002
     1023       148.549 753.748
     1032       903.889 326.476
     1041       408.248 577.327
     1050       189.239 92.5316
     106@edgeset
     107                length 
     1082       3       901.074
     1098       5       270.85 
     1106       9       601.553
     1115       9       285.022
     1129       4       408.091
     1133       0       719.712
     1147       5       612.836
     1150       4       933.353
     1165       0       778.871
     1175       5       0       
     1187       1       664.049
     1195       5       0       
     1200       9       560.464
     1214       8       352.36 
     1224       9       399.625
     1234       1       402.171
     1241       2       591.688
     1253       8       182.376
     1264       5       180.254
     1273       1       345.283
     1285       4       184.511
     1296       2       1112.45
     1300       1       556.624
     131@nodes
     132source  1       
     133target  8       
     134@end
     135\endcode
     136
     137Finally let us give a simple example that reads a graph from a file and writes
     138it to another.
     139
     140\todo This is to be done!
    59141
    60142</ol>
     
    63145usually solved using Dijkstra's algorithm. A utility
    64146that solves this is  the \ref lemon::Dijkstra "LEMON Dijkstra class".
    65 The following code is a simple program using the \ref lemon::Dijkstra "LEMON
    66 Dijkstra class" and it also shows how to define a map on the edges (the length
     147The 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
    67149function):
    68150
Note: See TracChangeset for help on using the changeset viewer.