DOLFINx  0.5.1
DOLFINx C++ interface
Public Member Functions | List of all members
AdjacencyList< T > Class Template Reference

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. More...

#include <AdjacencyList.h>

Public Member Functions

 AdjacencyList (const std::int32_t n)
 Construct trivial adjacency list where each of the n nodes is connected to itself. More...
 
template<typename U , typename V , typename = std::enable_if_t< std::is_same<std::vector<T>, std::decay_t<U>>::value && std::is_same<std::vector<std::int32_t>, std::decay_t<V>>::value>>
 AdjacencyList (U &&data, V &&offsets)
 Construct adjacency list from arrays of data. More...
 
template<typename X >
 AdjacencyList (const std::vector< X > &data)
 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). More...
 
 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
 Equality operator. More...
 
std::int32_t num_nodes () const
 Get the number of nodes. More...
 
int num_links (int node) const
 Number of connections for given node. More...
 
std::span< T > links (int node)
 Get the links (edges) for given node. More...
 
std::span< const T > links (int node) const
 Get the links (edges) for given node (const version) More...
 
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
 Informal string representation (pretty-print) More...
 

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]

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]

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]

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]

std::span<T> links ( int  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]

std::span<const T> links ( int  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()

int num_links ( int  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()

std::int32_t num_nodes ( ) const
inline

Get the number of nodes.

Returns
The number of nodes in the adjacency list

◆ operator==()

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

Equality operator.

Returns
True is the adjacency lists are equal

◆ str()

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: