graphs.dox
changeset 46 58557724a139
parent 38 236e7061b70d
child 50 72867897fcba
     1.1 --- a/graphs.dox	Mon Feb 22 00:43:23 2010 +0100
     1.2 +++ b/graphs.dox	Mon Feb 22 00:46:59 2010 +0100
     1.3 @@ -23,8 +23,8 @@
     1.4  The implementation of combinatorial algorithms heavily relies on
     1.5  efficient graph structures. Diverse applications require the
     1.6  usage of different physical graph storages.
     1.7 -In \ref sec_basics, we have introduced a general digraph structure,
     1.8 -\ref ListDigraph. Apart from this class, LEMON provides several
     1.9 +Until now, we used two general graph structures, \ref ListDigraph
    1.10 +and \ref ListGraph. Apart from these types, LEMON also provides several
    1.11  other classes for handling directed and undirected graphs to meet the
    1.12  diverging requirements of the possible users. In order to save on running
    1.13  time or on memory usage, some structures may fail to support some graph
    1.14 @@ -61,7 +61,7 @@
    1.15  all the LEMON algorithms and classes will work with them properly.
    1.16  
    1.17  
    1.18 -[SEC]sec_digraph_types[SEC] Digraph Structures
    1.19 +[SEC]sec_digraph_types[SEC] Directed Graph Structures
    1.20  
    1.21  The already used \ref ListDigraph class is the most versatile directed
    1.22  graph structure. As its name suggests, it is based on linked lists,
    1.23 @@ -90,123 +90,16 @@
    1.24  arcs or nodes, moreover, the class needs constant space in memory.
    1.25  
    1.26  
    1.27 -[SEC]sec_undir_graphs[SEC] Undirected Graphs
    1.28 +[SEC]sec_graph_types[SEC] Undirected Graph Structures
    1.29  
    1.30 -LEMON also provides undirected graph structures. For example,
    1.31 -\ref ListGraph and \ref SmartGraph are the undirected versions of
    1.32 -\ref ListDigraph and \ref SmartDigraph, respectively.
    1.33 -They provide similar features to the digraph structures.
    1.34 +The general undirected graph classes, \ref ListGraph and \ref SmartGraph
    1.35 +have similar implementations as their directed variants.
    1.36 +Therefore, \ref SmartDigraph is more efficient, but \ref ListGraph provides
    1.37 +more functionality.
    1.38  
    1.39 -The \ref concepts::Graph "undirected graphs" also fulfill the concept of
    1.40 -\ref concepts::Digraph "directed graphs", in such a way that each
    1.41 -undirected \e edge of a graph can also be regarded as two oppositely
    1.42 -directed \e arcs. As a result, all directed graph algorithms automatically
    1.43 -run on undirected graphs, as well.
    1.44 -
    1.45 -Undirected graphs provide an \c Edge type for the \e undirected \e edges
    1.46 -and an \c Arc type for the \e directed \e arcs. The \c Arc type is
    1.47 -convertible to \c Edge (or inherited from it), thus the corresponding
    1.48 -edge can always be obtained from an arc.
    1.49 -
    1.50 -Only nodes and edges can be added to or removed from an undirected
    1.51 -graph and the corresponding arcs are added or removed automatically
    1.52 -(there are twice as many arcs as edges)
    1.53 -
    1.54 -For example,
    1.55 -\code
    1.56 -  ListGraph g;
    1.57 -
    1.58 -  ListGraph::Node a = g.addNode();
    1.59 -  ListGraph::Node b = g.addNode();
    1.60 -  ListGraph::Node c = g.addNode();
    1.61 -
    1.62 -  ListGraph::Edge e = g.addEdge(a,b);
    1.63 -  g.addEdge(b,c);
    1.64 -  g.addEdge(c,a);
    1.65 -\endcode
    1.66 -
    1.67 -Each edge has an inherent orientation, thus it can be defined whether an
    1.68 -arc is forward or backward oriented in an undirected graph with respect
    1.69 -to this default oriantation of the represented edge.
    1.70 -The direction of an arc can be obtained and set using the functions
    1.71 -\ref concepts::Graph::direction() "direction()" and
    1.72 -\ref concepts::Graph::direct() "direct()", respectively.
    1.73 -
    1.74 -For example,
    1.75 -\code
    1.76 -  ListGraph::Arc a1 = g.direct(e, true);    // a1 is the forward arc
    1.77 -  ListGraph::Arc a2 = g.direct(e, false);   // a2 is the backward arc
    1.78 -
    1.79 -  if (a2 == g.oppositeArc(a1))
    1.80 -    std::cout << "a2 is the opposite of a1" << std::endl;
    1.81 -\endcode
    1.82 -
    1.83 -The end nodes of an edge can be obtained using the functions
    1.84 -\ref concepts::Graph::source() "u()" and
    1.85 -\ref concepts::Graph::target() "v()", while the
    1.86 -\ref concepts::Graph::source() "source()" and
    1.87 -\ref concepts::Graph::target() "target()" can be used for arcs.
    1.88 -
    1.89 -\code
    1.90 -  std::cout << "Edge " << g.id(e) << " connects node "
    1.91 -    << g.id(g.u(e)) << " and node " << g.id(g.v(e)) << std::endl;
    1.92 -
    1.93 -  std::cout << "Arc " << g.id(a2) << " goes from node "
    1.94 -    << g.id(g.source(a2)) << " to node " << g.id(g.target(a2)) << std::endl;
    1.95 -\endcode
    1.96 -
    1.97 -
    1.98 -Similarly to the digraphs, the undirected graphs also provide iterators
    1.99 -\ref concepts::Graph::NodeIt "NodeIt", \ref concepts::Graph::ArcIt "ArcIt",
   1.100 -\ref concepts::Graph::OutArcIt "OutArcIt" and \ref concepts::Graph::InArcIt
   1.101 -"InArcIt", which can be used the same way.
   1.102 -However, they also have iterator classes for edges.
   1.103 -\ref concepts::Graph::EdgeIt "EdgeIt" traverses all edges in the graph and
   1.104 -\ref concepts::Graph::IncEdgeIt "IncEdgeIt" lists the incident edges of a
   1.105 -certain node.
   1.106 -
   1.107 -For example, the degree of each node can be computed and stored in a node map
   1.108 -like this:
   1.109 -
   1.110 -\code
   1.111 -  ListGraph::NodeMap<int> deg(g, 0);
   1.112 -  for (ListGraph::NodeIt n(g); n != INVALID; ++n) {
   1.113 -    for (ListGraph::IncEdgeIt e(g, n); e != INVALID; ++e) {
   1.114 -      deg[n]++;
   1.115 -    }
   1.116 -  }
   1.117 -\endcode
   1.118 -
   1.119 -In an undirected graph, both \ref concepts::Graph::OutArcIt "OutArcIt"
   1.120 -and \ref concepts::Graph::InArcIt "InArcIt" iterates on the same \e edges
   1.121 -but with opposite direction. They are convertible to both \c Arc and
   1.122 -\c Edge types. \ref concepts::Graph::IncEdgeIt "IncEdgeIt" also iterates
   1.123 -on these edges, but it is not convertible to \c Arc, only to \c Edge.
   1.124 -
   1.125 -Apart from the node and arc maps, an undirected graph also defines
   1.126 -a template member class for constructing edge maps. These maps can be
   1.127 -used in conjunction with both edges and arcs.
   1.128 -
   1.129 -For example,
   1.130 -\code
   1.131 -  ListGraph::EdgeMap cost(g);
   1.132 -  cost[e] = 10;
   1.133 -  std::cout << cost[e] << std::endl;
   1.134 -  std::cout << cost[a1] << ", " << cost[a2] << std::endl;
   1.135 -
   1.136 -  ListGraph::ArcMap arc_cost(g);
   1.137 -  arc_cost[a1] = cost[a1];
   1.138 -  arc_cost[a2] = 2 * cost[a2];
   1.139 -  // std::cout << arc_cost[e] << std::endl;   // this is not valid
   1.140 -  std::cout << arc_cost[a1] << ", " << arc_cost[a2] << std::endl;
   1.141 -\endcode
   1.142 -
   1.143 -[SEC]sec_special_graphs[SEC] Special Graph Structures
   1.144 -
   1.145 -In addition to the general undirected classes \ref ListGraph and
   1.146 -\ref SmartGraph, LEMON also provides special purpose graph types for
   1.147 -handling \ref FullGraph "full graphs", \ref GridGraph "grid graphs" and
   1.148 -\ref HypercubeGraph "hypercube graphs".
   1.149 +In addition to these general structures, LEMON also provides special purpose
   1.150 +undirected graph types for handling \ref FullGraph "full graphs",
   1.151 +\ref GridGraph "grid graphs" and \ref HypercubeGraph "hypercube graphs".
   1.152  They all static structures, i.e. they do not allow distinct item additions
   1.153  or deletions, the graph has to be built at once.
   1.154