Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/dolfinx/v0.9.0/cpp/doxygen/df/d84/classdolfinx_1_1graph_1_1AdjacencyList.html
DOLFINx 0.7.3
DOLFINx C++ interface
Loading...
Searching...
No Matches
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.
 
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)
 Construct adjacency list from arrays of data.
 
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).
 
 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.
 
std::int32_t num_nodes () const
 Get the number of nodes.
 
int num_links (std::size_t node) const
 Number of connections for given node.
 
std::span< Tlinks (std::size_t node)
 Get the links (edges) for given node.
 
std::span< const Tlinks (std::size_t node) const
 Get the links (edges) for given node (const version)
 
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)
 

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: