Some more documentation (sorry, I forgot to check the doxygen.log and now I am under windows)
authorathos
Thu, 03 Mar 2005 17:20:08 +0000
changeset 11838f623d1833a7
parent 1182 a1abe9452199
child 1184 aad134c6c9c5
Some more documentation (sorry, I forgot to check the doxygen.log and now I am under windows)
doc/maps.dox
doc/quicktour.dox
     1.1 --- a/doc/maps.dox	Thu Mar 03 17:18:27 2005 +0000
     1.2 +++ b/doc/maps.dox	Thu Mar 03 17:20:08 2005 +0000
     1.3 @@ -12,7 +12,8 @@
     1.4    typedef double Value;
     1.5  \endcode
     1.6  
     1.7 -A map can \e readable (\ref lemon::concept::ReadMap "ReadMap", for short),
     1.8 +A map can be 
     1.9 +\e readable (\ref lemon::concept::ReadMap "ReadMap", for short),
    1.10  \e writable (\ref lemon::concept::WriteMap "WriteMap") or both
    1.11  (\ref lemon::concept::ReadWriteMap "ReadWriteMap").
    1.12  There also exists a special type of
    1.13 @@ -144,4 +145,4 @@
    1.14  To be written...
    1.15  
    1.16  */
    1.17 -}
    1.18 \ No newline at end of file
    1.19 +}
     2.1 --- a/doc/quicktour.dox	Thu Mar 03 17:18:27 2005 +0000
     2.2 +++ b/doc/quicktour.dox	Thu Mar 03 17:20:08 2005 +0000
     2.3 @@ -10,11 +10,15 @@
     2.4  frequently when <b>designing and testing certain networks</b>, for example
     2.5  in telecommunication, computer networks, and other areas that I cannot
     2.6  think of now. A very natural way of modelling these networks is by means
     2.7 -of a <b> graph</b> (we will always mean a directed graph by that). 
     2.8 +of a <b> graph</b> (we will always mean a directed graph by that and say
     2.9 +<b> undirected graph </b> otherwise). 
    2.10  So if you want to write a program that works with 
    2.11 -graphs then you might find it useful to use our library LEMON.
    2.12 +graphs then you might find it useful to use our library LEMON. LEMON 
    2.13 +defines various graph concepts depending on what you want to do with the 
    2.14 +graph: a very good description can be found in the page
    2.15 +about \ref graphs "graphs".
    2.16  
    2.17 -
    2.18 +You will also want to assign data to the edges or nodes of the graph, for example a length or capacity function defined on the edges. You can do this in LEMON using so called \ref maps "maps". You can define a map on the nodes or on the edges of the graph and the value of the map (the range of the function) can be practically almost any type. Read more about maps \ref maps-page "here".
    2.19  
    2.20  Some examples are the following (you will find links next to the code fragments that help to download full demo programs):
    2.21  
    2.22 @@ -44,33 +48,88 @@
    2.23  If you want to read more on the LEMON graph structures and concepts, read the page about \ref graphs "graphs". 
    2.24  
    2.25  -# 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.26 -in that format (find the documentation of the format on the web). 
    2.27 +in that format (find the documentation of the DIMECS file format on the web). 
    2.28  \code
    2.29  Graph g;
    2.30  std::ifstream f("graph.dim");
    2.31  readDimacs(f, g);
    2.32  \endcode
    2.33 -One can also store network (graph+capacity on the edges) instances and other things in DIMACS format: to see the details read the documentation of the \ref dimacs.h "Dimacs file format reader".
    2.34 +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.35  
    2.36  
    2.37  - If you want to solve some transportation problems in a network then 
    2.38  you will want to find shortest paths between nodes of a graph. This is 
    2.39  usually solved using Dijkstra's algorithm. A utility
    2.40  that solves this is  the \ref lemon::Dijkstra "LEMON Dijkstra class".
    2.41 -A simple program using the \ref lemon::Dijkstra "LEMON Dijkstra class" is
    2.42 -as follows (we do not include the part that instantiates the graph and the length function):
    2.43 +The following code is a simple program using the \ref lemon::Dijkstra "LEMON
    2.44 +Dijkstra class" and it also shows how to define a map on the edges (the length
    2.45 +function):
    2.46  
    2.47  \code
    2.48 -  typedef Graph::EdgeMap<int> LengthMap;
    2.49 -  Graph G;
    2.50 -  Node s, t;
    2.51 -  LengthMap cap(G);
    2.52 -	...
    2.53 -  Dijkstra<Graph, LengthMap> 
    2.54 -	dijkstra_test(G, cap);
    2.55 -  dijkstra_test.run(s);
    2.56 +
    2.57 +    typedef ListGraph Graph;
    2.58 +    typedef Graph::Node Node;
    2.59 +    typedef Graph::Edge Edge;
    2.60 +    typedef Graph::EdgeMap<int> LengthMap;
    2.61 +
    2.62 +    Graph g;
    2.63 +
    2.64 +    //An example from Ahuja's book
    2.65 +
    2.66 +    Node s=g.addNode();
    2.67 +    Node v2=g.addNode();
    2.68 +    Node v3=g.addNode();
    2.69 +    Node v4=g.addNode();
    2.70 +    Node v5=g.addNode();
    2.71 +    Node t=g.addNode();
    2.72 +
    2.73 +    Edge s_v2=g.addEdge(s, v2);
    2.74 +    Edge s_v3=g.addEdge(s, v3);
    2.75 +    Edge v2_v4=g.addEdge(v2, v4);
    2.76 +    Edge v2_v5=g.addEdge(v2, v5);
    2.77 +    Edge v3_v5=g.addEdge(v3, v5);
    2.78 +    Edge v4_t=g.addEdge(v4, t);
    2.79 +    Edge v5_t=g.addEdge(v5, t);
    2.80 +  
    2.81 +    LengthMap len(g);
    2.82 +
    2.83 +    len.set(s_v2, 10);
    2.84 +    len.set(s_v3, 10);
    2.85 +    len.set(v2_v4, 5);
    2.86 +    len.set(v2_v5, 8);
    2.87 +    len.set(v3_v5, 5);
    2.88 +    len.set(v4_t, 8);
    2.89 +    len.set(v5_t, 8);
    2.90 +
    2.91 +    std::cout << "The id of s is " << g.id(s)<< ", the id of t is " << g.id(t)<<"."<<std::endl;
    2.92 +
    2.93 +    std::cout << "Dijkstra algorithm test..." << std::endl;
    2.94 +
    2.95 +    Dijkstra<Graph, LengthMap> dijkstra_test(g,len);
    2.96 +    
    2.97 +    dijkstra_test.run(s);
    2.98 +
    2.99 +    
   2.100 +    std::cout << "The distance of node t from node s: " << dijkstra_test.dist(t)<<std::endl;
   2.101 +
   2.102 +    std::cout << "The shortest path from s to t goes through the following nodes (the first one is t, the last one is s): "<<std::endl;
   2.103 +
   2.104 +    for (Node v=t;v != s; v=dijkstra_test.predNode(v)){
   2.105 +	std::cout << g.id(v) << "<-";
   2.106 +    }
   2.107 +    std::cout << g.id(s) << std::endl;	
   2.108  \endcode
   2.109  
   2.110 +See the whole program in \file dijkstra_demo.cc.
   2.111 +
   2.112 +The first part of the code is self-explanatory: we build the graph and set the
   2.113 +length values of the edges. Then we instantiate a member of the Dijkstra class
   2.114 +and run the Dijkstra algorithm from node \c s. After this we read some of the
   2.115 +results. 
   2.116 +You can do much more with the Dijkstra class, for example you can run it step
   2.117 +by step and gain full control of the execution. For a detailed description, see the documentation of the \ref lemon::Dijkstra "LEMON Dijkstra class".
   2.118 +
   2.119 +
   2.120  - If you want to design a network and want to minimize the total length
   2.121  of wires then you might be looking for a <b>minimum spanning tree</b> in
   2.122  an undirected graph. This can be found using the Kruskal algorithm: the 
   2.123 @@ -82,19 +141,4 @@
   2.124  \endcode
   2.125  
   2.126  
   2.127 -
   2.128 -Some more detailed introduction can be obtained by following the links 
   2.129 -below:
   2.130 -
   2.131 -\ref graphs "Graph structures"
   2.132 -play a central role in LEMON, so if you are new to the library,
   2.133 -you probably should start \ref graphs "here".
   2.134 -(You can also find that page along with others under
   2.135 -<a class="el" href="pages.html"> Related Pages </a>.)
   2.136 -
   2.137 -If you are 
   2.138 -interested in data structures and algorithms in more details, then
   2.139 -you should browse the reference manual part of the documentation.
   2.140 -Section <a class="el" href="modules.html"> Modules </a>
   2.141 - is a good starting point for this.
   2.142  */