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

The GRAPH with lists of adjacency of section 9.4 [see Graph.h]: for each node the LIST of its adjacent nodes and of the weights of the edges, \( \Theta( n + m ) \) space, adj( u ) in \( \Theta( |\mathrm{adj}( u )| ) \), hasEdge( u , v ) in \( O( |\mathrm{adj}( u )| ) \), all the edges in \( \Theta( n + m ) \), deleteNode() in \( O( n + m ) \). More...

#include "ADS/Contract.h"
#include "ADS/Iterators.h"
#include "ADS/graph/Graph.h"
#include "ADS/sequence/List.h"
#include <algorithm>
#include <concepts>
#include <optional>
#include <ranges>
#include <utility>
#include <variant>
#include <vector>
#include "ADS/graph/impl/ListGraph.tpp"

Go to the source code of this file.

Classes

class  ADS::ListGraph< W, T >
 a graph with lists of adjacency More...

Namespaces

namespace  ADS

Detailed description

The GRAPH with lists of adjacency of section 9.4 [see Graph.h]: for each node the LIST of its adjacent nodes and of the weights of the edges, \( \Theta( n + m ) \) space, adj( u ) in \( \Theta( |\mathrm{adj}( u )| ) \), hasEdge( u , v ) in \( O( |\mathrm{adj}( u )| ) \), all the edges in \( \Theta( n + m ) \), deleteNode() in \( O( n + m ) \).

The contracts [see Contract.h]: insertEdge() and deleteEdge() need two distinct nodes, deleteNode(), adj(), forEachAdj() and forEachEdge() a node; the invariant is that the lists hold only nodes of the graph, without loops nor repetitions, m() edges in all, and that an unoriented edge is in the lists of both its ends with the same weight. The insertions and the deletions of edges check it on the lists of the two ends, in \( O( d \log d ) \) for d adjacent nodes, deleteNode() on the whole graph. The operations are defined in ListGraph.tpp.

See also
A. Montresor, Algoritmi e Strutture Dati, 2025, section 9.4, https://algoritmicamente.it/materiali/libro/capitoli/cap09.pdf
P. Morin, Open Data Structures (in C++), Edition 0.1G, 2013, https://opendatastructures.org/ods-cpp.pdf, section 12.2
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa