34#ifndef __ADS_MatrixGraph
35 #define __ADS_MatrixGraph
64template<
class W = std::monostate ,
class T = std::monostate >
110 [[nodiscard]]
bool hasEdge(
int u ,
int v )
const;
114 [[nodiscard]] std::optional< W >
weight(
int u ,
int v )
const;
119 [[nodiscard]] std::vector< int >
adj(
int u )
const;
138 [[nodiscard]] std::vector< int >
inAdj(
int u )
const;
154 static std::size_t
size(
const auto & r ) {
return( r.size() ); }
156 static bool occupied(
const auto & r , std::size_t i ) {
157 return( r[ i ].has_value() );
160 static int read(
const auto & , std::size_t i ) {
return(
int( i ) ); }
167 const auto & r = f_M[ this->
check( u ) ];
168 return( std::ranges::subrange( It( &r , 0 ) , It( &r , r.size() ) ) );
176 [[nodiscard]]
bool consistent(
void )
const;
180 [[nodiscard]]
bool consistentAt(
int u )
const;
182 std::vector< std::vector< std::optional< W > > > f_M;
194#include "ADS/graph/impl/MatrixGraph.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
The iterators that the containers of the library have in common, beyond the book: they give a contain...
GraphNodes(int n, bool directed)
int n(void) const
Definition Graph.h:126
bool directed(void) const
Definition Graph.h:123
void forEachAdj(int u, F &&f) const
void forEachEdge(int u, F &&f) const
std::optional< W > weight(int u, int v) const
the weight of , nothing (the infinity of the book) if there is no such edge
std::vector< int > adj(int u) const
the set of the nodes adjacent to , in increasing order, time
T Label
the type of the labels
Definition MatrixGraph.h:73
bool hasEdge(int u, int v) const
time
std::vector< int > inAdj(int u) const
the nodes with an edge to , in increasing order, the column of , time (the inEdges( i ) of the Adjac...
void insertEdge(int u, int v, const W &w=W())
the edge , or , of weight , time; only the weight changes if it is there
MatrixGraph(int n=0, bool directed=true)
the graph of the nodes , with no edge
W Weight
the type of the weights
Definition MatrixGraph.h:72
void deleteEdge(int u, int v)
void deleteNode(int u)
removes the node and its edges, time
auto neighbors(int u) const
the nodes adjacent to in increasing order, bidirectional
Definition MatrixGraph.h:165
int insertNode(const T &t=T())
a new node, a new row and a new column, time
a bidirectional iterator on the occupied places of the table O, by the policy P with the static funct...
Definition Iterators.h:691
The GRAPH of chapter 9 and its realizations.
the columns of the edges in a row, for SlotIterator
Definition MatrixGraph.h:152
static int read(const auto &, std::size_t i)
the node of the column
Definition MatrixGraph.h:160
static bool occupied(const auto &r, std::size_t i)
whether the column holds an edge
Definition MatrixGraph.h:156
static std::size_t size(const auto &r)
the number of the columns
Definition MatrixGraph.h:154