Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Digraph< BaseGraph > Class Template Reference

Generic directed graph (digraph) wrapper template. More...

#include <graph-dry.H>

Inheritance diagram for Aleph::Digraph< BaseGraph >:
[legend]
Collaboration diagram for Aleph::Digraph< BaseGraph >:
[legend]

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.
 

Detailed Description

template<class BaseGraph>
class Aleph::Digraph< BaseGraph >

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:

  • Default construction
  • Copy construction (deep copy via copy_graph)
  • Move construction (via swap)
  • Copy assignment
  • Move assignment
Template Parameters
BaseGraphThe 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>>;

See also
List_Graph List_SGraph Array_Graph

Definition at line 4376 of file graph-dry.H.

Member Typedef Documentation

◆ Arc

template<class BaseGraph >
using Aleph::Digraph< BaseGraph >::Arc = typename BaseGraph::Arc

Definition at line 4381 of file graph-dry.H.

◆ GT

template<class BaseGraph >
using Aleph::Digraph< BaseGraph >::GT = BaseGraph

Definition at line 4379 of file graph-dry.H.

◆ Node

template<class BaseGraph >
using Aleph::Digraph< BaseGraph >::Node = typename BaseGraph::Node

Definition at line 4380 of file graph-dry.H.

Constructor & Destructor Documentation

◆ Digraph() [1/3]

template<class BaseGraph >
Aleph::Digraph< BaseGraph >::Digraph ( )
inlinenoexcept

Default constructor.

Creates an empty directed graph.

Definition at line 4387 of file graph-dry.H.

◆ Digraph() [2/3]

template<class BaseGraph >
Aleph::Digraph< BaseGraph >::Digraph ( const Digraph< BaseGraph > &  dg)
inline

Copy constructor.

Creates a deep copy of the given digraph. All nodes and arcs are duplicated, preserving the graph topology.

Parameters
[in]dgThe digraph to copy.

Definition at line 4399 of file graph-dry.H.

◆ Digraph() [3/3]

template<class BaseGraph >
Aleph::Digraph< BaseGraph >::Digraph ( Digraph< BaseGraph > &&  dg)
inlinenoexcept

Move constructor.

Transfers ownership of all nodes and arcs from dg to this digraph. After the move, dg will be empty.

Parameters
[in]dgThe digraph to move from.

Definition at line 4412 of file graph-dry.H.

Member Function Documentation

◆ get_in_it()

template<class BaseGraph >
In_Iterator Aleph::Digraph< BaseGraph >::get_in_it ( Node *  p) const
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)\).

Parameters
[in]pa node of the digraph.

Definition at line 4459 of file graph-dry.H.

◆ operator=() [1/2]

template<class BaseGraph >
Digraph & Aleph::Digraph< BaseGraph >::operator= ( const Digraph< BaseGraph > &  g)
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.

Parameters
[in]gThe digraph to copy.
Returns
Reference to this digraph.
Exceptions
bad_allocif there is not enough memory for the copy.

Definition at line 4471 of file graph-dry.H.

◆ operator=() [2/2]

template<class BaseGraph >
Digraph & Aleph::Digraph< BaseGraph >::operator= ( Digraph< BaseGraph > &&  g)
inlinenoexcept

Move assignment operator.

Transfers ownership of all nodes and arcs from g to this digraph. After the move, g will be empty.

Parameters
[in]gThe digraph to move from.
Returns
Reference to this digraph.

Definition at line 4491 of file graph-dry.H.

◆ swap() [1/2]

template<class BaseGraph >
void Aleph::Digraph< BaseGraph >::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.

◆ swap() [2/2]

template<class BaseGraph >
void Aleph::Digraph< BaseGraph >::swap ( Digraph< BaseGraph > &  g)
inlinenoexcept

Swap in constant time this digraph with g.

Parameters
[in]gThe digraph to swap with.

Definition at line 4422 of file graph-dry.H.

Referenced by TEST().


The documentation for this class was generated from the following files: