|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Generic directed graph (digraph) wrapper template. More...
#include <graph-dry.H>
Classes | |
| struct | In_Iterator |
| Iterator on the arcs that go into a node of the digraph. More... | |
Public Types | |
| using | GT = BaseGraph |
| using | Node = typename BaseGraph::Node |
| using | Arc = typename BaseGraph::Arc |
Public Member Functions | |
| Digraph () noexcept | |
| Default constructor. | |
| Digraph (const Digraph &dg) | |
| Copy constructor. | |
| Digraph (Digraph &&dg) noexcept | |
| Move constructor. | |
| void | swap (Digraph &g) noexcept |
Swap in constant time this digraph with g. | |
| void | swap (BaseGraph &g)=delete |
| A digraph does not swap with an undirected graph: the swap of the base graph would give this digraph the arcs of the other graph, and its flag, which says that it is not directed. | |
| In_Iterator | get_in_it (Node *p) const |
Return an iterator on the arcs that go into p: those of the arcs of the digraph whose target is p, in \(O(E)\). | |
| Digraph & | operator= (const Digraph &g) |
| Copy assignment operator. | |
| Digraph & | operator= (Digraph &&g) noexcept |
| Move assignment operator. | |
Generic directed graph (digraph) wrapper template.
This template wraps any undirected graph class and converts it into a directed graph by setting the digraph flag to true. This eliminates code duplication across the various digraph implementations (List_Digraph, List_SDigraph, Array_Digraph).
The wrapper properly handles:
copy_graph)| BaseGraph | The undirected graph class to wrap (e.g., List_Graph, List_SGraph, Array_Graph). |
Example usage: cpp Instead of defining a separate List_Digraph class: template <typename Node, typename Arc> using List_Digraph = Digraph<List_Graph<Node, Arc>>;
Definition at line 4376 of file graph-dry.H.
| using Aleph::Digraph< BaseGraph >::Arc = typename BaseGraph::Arc |
Definition at line 4381 of file graph-dry.H.
| using Aleph::Digraph< BaseGraph >::GT = BaseGraph |
Definition at line 4379 of file graph-dry.H.
| using Aleph::Digraph< BaseGraph >::Node = typename BaseGraph::Node |
Definition at line 4380 of file graph-dry.H.
|
inlinenoexcept |
|
inline |
Copy constructor.
Creates a deep copy of the given digraph. All nodes and arcs are duplicated, preserving the graph topology.
| [in] | dg | The digraph to copy. |
Definition at line 4399 of file graph-dry.H.
|
inlinenoexcept |
Move constructor.
Transfers ownership of all nodes and arcs from dg to this digraph. After the move, dg will be empty.
| [in] | dg | The digraph to move from. |
Definition at line 4412 of file graph-dry.H.
|
inline |
Return an iterator on the arcs that go into p: those of the arcs of the digraph whose target is p, in \(O(E)\).
| [in] | p | a node of the digraph. |
Definition at line 4459 of file graph-dry.H.
|
inline |
Copy assignment operator.
Replaces the contents of this digraph with a deep copy of g. The copy is made first, so that if it throws this digraph is as it was. The digraph keeps its cookie.
| [in] | g | The digraph to copy. |
| bad_alloc | if there is not enough memory for the copy. |
Definition at line 4471 of file graph-dry.H.
|
inlinenoexcept |
Move assignment operator.
Transfers ownership of all nodes and arcs from g to this digraph. After the move, g will be empty.
| [in] | g | The digraph to move from. |
Definition at line 4491 of file graph-dry.H.
|
delete |
A digraph does not swap with an undirected graph: the swap of the base graph would give this digraph the arcs of the other graph, and its flag, which says that it is not directed.
|
inlinenoexcept |
Swap in constant time this digraph with g.
| [in] | g | The digraph to swap with. |
Definition at line 4422 of file graph-dry.H.
Referenced by TEST().