ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
Digraphs.h File Reference

The graphs of ADS as digraphs of LEMON and the digraphs of LEMON as graphs of ADS, beyond the book (see Interoperation with LEMON): More...

#include "ADS/Contract.h"
#include "ADS/graph/Graph.h"
#include "ADS/graph/StaticGraph.h"
#include <lemon/bits/graph_extender.h>
#include <lemon/core.h>
#include <cstddef>
#include <tuple>
#include <vector>

Go to the source code of this file.

Classes

class  ADS::lemon_interop::StaticDigraphBase< W, L >
 the base of lemon::DigraphExtender on a StaticGraph< W , L >: the arcs are the places of its compressed rows More...
struct  ADS::lemon_interop::StaticDigraphBase< W, L >::Node
 a node, by its name in the graph of ADS More...
struct  ADS::lemon_interop::StaticDigraphBase< W, L >::Arc
 an arc, by its place in the rows More...
class  ADS::lemon_interop::StaticDigraphView< W, L >
 a StaticGraph< W , L > of ADS as a digraph of LEMON, with no copy of its rows More...
struct  ADS::lemon_interop::StaticDigraphView< W, L >::WeightMap
 the weights of the arcs, a ReadMap of LEMON More...
class  ADS::lemon_interop::GraphView< GR, LM >
 a digraph of LEMON and a length map as a GRAPH of ADS, with no copy, the names of the nodes their ids More...

Namespaces

namespace  ADS
namespace  ADS::lemon_interop

Functions

template<class GR, class LM>
StaticGraph< typename LM::Value > ADS::lemon_interop::toStatic (const GR &g, const LM &l)
 the copy of the digraph \( g \) of LEMON with the lengths \( l \) into a StaticGraph of ADS, the nodes by their ids and the loops left out, in \( \Theta( n + m ) \) time

Detailed description

The graphs of ADS as digraphs of LEMON and the digraphs of LEMON as graphs of ADS, beyond the book (see Interoperation with LEMON):

  • StaticDigraphView< W , L >, a model of lemon::concepts::Digraph over a StaticGraph< W , L > of ADS [see StaticGraph.h] of either layout, with no copy of its rows: the base of lemon::DigraphExtender, which supplies the iterators, the maps and the notifiers, on the places of the compressed rows, the arc \( k \) being the place \( k \) of arcHeads(), so that OutArcIt walks the row in memory, and weights() a ReadMap of the weights in the same places of arcWeights(). source() and InArcIt need what the rows lack, a tail per arc and the lists of the arcs into each node, built once in \( \Theta( n + a ) \) time and \( 8 a + 4 n \) bytes (the StaticDigraph of LEMON keeps 16 a + 8 n). An unoriented StaticGraph is seen with its two arcs per edge. The algorithms of LEMON (Dijkstra, Bfs, Dfs, Preflow, NetworkSimplex, ...) then run on the graph of ADS by replacing the graph and the length map, and any other graph of ADS reaches them through the copy StaticGraph( g ). A static graph never changes, so that the notifiers tell only the build() of the construction, as those of the StaticDigraph of LEMON;
  • GraphView< GR , LM >, a GRAPH of ADS [see Graph.h] over a digraph of LEMON and a length map, with no copy: the names of the nodes are the ids of LEMON, bound() is maxNodeId() + 1, hasNode() asks valid() where the graph has it, and forEachEdge() walks OutArcIt and reads the map, so that the algorithms of the book [see ShortestPaths.h, Visit.h] run on the graph of LEMON; the layout is that of LEMON;
  • toStatic( g , l ), the copy of a digraph of LEMON into a StaticGraph of ADS, once, in \( \Theta( n + m ) \) time and \( 4 n + ( 4 + s ) m \) bytes for lengths of \( s \) bytes, the nodes by their ids and the loops left out, on which the parallel algorithms of ADS [see ParallelShortestPaths.h, ParallelGraph.h] take their path on the compressed rows; their results, by the ids, go back into a map of LEMON by nodeFromId().

Reading a graph of LEMON from several threads is safe while nobody changes it, since its iterators and its maps only read arrays.

The contracts [see Contract.h]: the graph of ADS outlives its view; the weights of weights() exist only on a weighted StaticGraph. The classes are defined in this file.

See also
B. Dezső, A. Jüttner, P. Kovács, LEMON - an open source C++ graph template library, Electronic Notes in Theoretical Computer Science 264(5), 23-45, 2011, doi:10.1016/j.entcs.2011.06.003
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa