DOLFINx 0.9.0
DOLFINx C++ interface
Loading...
Searching...
No Matches
AdjacencyList< T > Class Template Reference

#include <AdjacencyList.h>

Public Member Functions

 AdjacencyList (const std::int32_t n)
 
template<typename U , typename V >
requires std::is_convertible_v<std::remove_cvref_t<U>, std::vector<T>> and std::is_convertible_v<std::remove_cvref_t<V>, std::vector<std::int32_t>>
 AdjacencyList (U &&data, V &&offsets)
 
template<typename X >
 AdjacencyList (const std::vector< X > &data)
 
 AdjacencyList (const AdjacencyList &list)=default
 Copy constructor.
 
 AdjacencyList (AdjacencyList &&list)=default
 Move constructor.
 
 ~AdjacencyList ()=default
 Destructor.
 
AdjacencyListoperator= (const AdjacencyList &list)=default
 Assignment operator.
 
AdjacencyListoperator= (AdjacencyList &&list)=default
 Move assignment operator.
 
bool operator== (const AdjacencyList &list) const
 
std::int32_t num_nodes () const
 
int num_links (std::size_t node) const
 
std::span< T > links (std::size_t node)
 
std::span< const T > links (std::size_t node) const
 
const std::vector< T > & array () const
 Return contiguous array of links for all nodes (const version)
 
std::vector< T > & array ()
 Return contiguous array of links for all nodes.
 
const std::vector< std::int32_t > & offsets () const
 Offset for each node in array() (const version)
 
std::vector< std::int32_t > & offsets ()
 Offset for each node in array()
 
std::string str () const
 

Detailed Description

template<typename T>
class dolfinx::graph::AdjacencyList< T >

This class provides a static adjacency list data structure. It is commonly used to store directed graphs. For each node in the contiguous list of nodes [0, 1, 2, ..., n) it stores the connected nodes. The representation is strictly local, i.e. it is not parallel aware.

Constructor & Destructor Documentation

◆ AdjacencyList() [1/3]

template<typename T >
AdjacencyList ( const std::int32_t n)
inlineexplicit

Construct trivial adjacency list where each of the n nodes is connected to itself

Parameters
[in]nNumber of nodes

◆ AdjacencyList() [2/3]

template<typename T >
template<typename U , typename V >
requires std::is_convertible_v<std::remove_cvref_t<U>, std::vector<T>> and std::is_convertible_v<std::remove_cvref_t<V>, std::vector<std::int32_t>>
AdjacencyList ( U && data,
V && offsets )
inline

Construct adjacency list from arrays of data

Parameters
[in]dataAdjacency array
[in]offsetsThe index to the adjacency list in the data array for node i

◆ AdjacencyList() [3/3]

template<typename T >
template<typename X >
AdjacencyList ( const std::vector< X > & data)
inlineexplicit

Set all connections for all entities (T is a '2D' container, e.g. a std::vector<<std::vector<std::size_t>>, std::vector<<std::set<std::size_t>>, etc).

Parameters
[in]dataAdjacency list data, where std::next(data, i) points to the container of edges for node i.

Member Function Documentation

◆ links() [1/2]

template<typename T >
std::span< T > links ( std::size_t node)
inline

Get the links (edges) for given node

Parameters
[in]nodeNode index
Returns
Array of outgoing links for the node. The length will be AdjacencyList::num_links(node).

◆ links() [2/2]

template<typename T >
std::span< const T > links ( std::size_t node) const
inline

Get the links (edges) for given node (const version)

Parameters
[in]nodeNode index
Returns
Array of outgoing links for the node. The length will be AdjacencyList:num_links(node).

◆ num_links()

template<typename T >
int num_links ( std::size_t node) const
inline

Number of connections for given node

Parameters
[in]nodeNode index
Returns
The number of outgoing links (edges) from the node

◆ num_nodes()

template<typename T >
std::int32_t num_nodes ( ) const
inline

Get the number of nodes

Returns
The number of nodes in the adjacency list

◆ operator==()

template<typename T >
bool operator== ( const AdjacencyList< T > & list) const
inline

Equality operator

Returns
True is the adjacency lists are equal

◆ str()

template<typename T >
std::string str ( ) const
inline

Informal string representation (pretty-print)

Returns
String representation of the adjacency list

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