119inline constexpr int INF = std::numeric_limits< int >::max();
128inline constexpr int NIL = -1;
160std::pair< std::vector< int > , std::vector< std::pair< int , int > > >
183template< Graph G ,
class FN ,
class FE >
184void bfs(
const G & g ,
int r , FN && node , FE && edge );
211std::pair< std::vector< int > , std::vector< int > >
distance(
const G & g ,
226template< Graph G ,
class Q >
227 requires requires( Q q ,
int v )
230 { q.dequeue() } -> std::convertible_to< int >;
232std::pair< std::vector< int > , std::vector< int > >
254inline std::vector< int >
path(
int r ,
int s ,
const std::vector< int > & p );
299template< Graph G ,
class Pre ,
class Edge ,
class Post >
300void dfs(
const G & g ,
int u , std::vector< bool > & visited , Pre && pre ,
301 Edge && edge , Post && post );
329std::vector< int >
cc(
const G & g , std::vector< int > S );
345std::vector< int >
cc(
const G & g );
394 template<
class Edge >
398 template<
class Edge >
402 [[nodiscard]]
int dt(
int u )
const;
405 [[nodiscard]]
int ft(
int u )
const;
410 std::vector< int > f_dt;
411 std::vector< int > f_ft;
544std::vector< int >
scc(
const G & g );
579#include "ADS/graph/impl/Visit.tpp"
The QUEUE of the book [see ADT.h] realized with a circular vector of places, the place 0 following t...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The GRAPH with lists of adjacency of section 9.4 [see Graph.h]: for each node the LIST of its adjacen...
The strongly connected components of an oriented graph by one visit in depth, beyond the book,...
void visit(int u, Edge &&edge)
the visit from ; edge( u , v , k ) on each edge examined, of kind
void visitAll(Edge &&edge)
the visits from all the nodes not discovered yet, in increasing order
a graph with lists of adjacency
Definition ListGraph.h:71
The GRAPH of chapter 9 and its realizations.
std::vector< int > topsortKahn(const G &g)
the topological order by removing the nodes with no entering edge, in the order of V() and then of di...
void dfs(const G &g, int u, std::vector< bool > &visited, Pre &&pre, Edge &&edge, Post &&post)
the visit in depth from , calling pre( u ) in the previsit, edge( u , v ) on each edge and post( u ) ...
bool isTopologicalOrder(const G &g, const std::vector< int > &S)
whether has each node once and each edge has before
void bfs(const G &g, int r, FN &&node, FE &&edge)
the visit in breadth from , calling node( u ) when is examined and edge( u , v ) when is examined
std::pair< std::vector< int >, std::vector< std::pair< int, int > > > genericVisit(const G &g, int r, Choice c)
the general visit from : the nodes in the order in which they join , and the edges of the tree in th...
constexpr int NIL
no node
Definition Visit.h:128
std::vector< int > cc(const G &g, std::vector< int > S)
the component of each node, numbered from 1, the visits starting from the nodes as they leave the sta...
std::vector< int > topsort(const G &g)
the nodes by decreasing finish time, which for an acyclic graph is a topological order; the first is ...
bool hasCycle(const G &g)
true if the oriented graph has a cycle, i.e., if a visit finds a back edge; on an unoriented graph ea...
ListGraph transpose(const G &g)
the transposed graph, with the edges reversed
EdgeKind
the kind of an edge with respect to a depth-first visit
Definition Visit.h:352
std::pair< std::vector< int >, std::vector< int > > distance(const G &g, int r)
the distances from , INF if not reachable, and the parents in the tree of the shortest paths,...
constexpr int INF
the infinite distance
Definition Visit.h:119
std::vector< int > scc(const G &g)
the strongly connected component of each node, numbered from 1
Choice
the node of that genericVisit() chooses
Definition Visit.h:122
std::vector< int > path(int r, int s, const std::vector< int > &p)
the path from to in the tree of the parents , empty if there is none (the procedure printPath of th...
bool unilaterallyConnected(const G &g)
true if every two nodes have a path between them in one direction
@ CROSS
any other edge, between two subtrees or two trees
Definition Visit.h:356
@ BACK
an edge to an ancestor, not finished yet
Definition Visit.h:354
@ FORWARD
an edge to a descendant, already finished
Definition Visit.h:355
@ TREE
an edge of the tree of the visit, to a node not discovered
Definition Visit.h:353
@ NEWEST
the last one added: the visit in depth
Definition Visit.h:123
@ OLDEST
the first one added: the visit in breadth
Definition Visit.h:124
what a visit did: the nodes taken out of its structure and the edges examined
Definition Visit.h:217
long long edges
Definition Visit.h:218
long long nodes
Definition Visit.h:218