DOLFIN-X
DOLFIN-X C++ interface
Public Member Functions | List of all members
dolfinx::graph::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 , std::enable_if_t< std::is_base_of< Eigen::EigenBase< std::decay_t< V >>, std::decay_t< V >>::value, int > = 0>
 AdjacencyList (U &&data, V &&offsets)
 Construct adjacency list from arrays of data (Eigen data types) More...
 
template<typename U , typename V , std::enable_if_t<!std::is_base_of< Eigen::EigenBase< std::decay_t< V >>, std::decay_t< V >>::value, int > = 0>
 AdjacencyList (U &&data, V &&offsets)
 Construct adjacency list from arrays of data (non-Eigen data types) More...
 
 AdjacencyList (const Eigen::Ref< const Eigen::Array< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor >> &matrix)
 Construct adjacency list for a problem with a fixed number of links (edges) for each node. 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.
 
AdjacencyListoperator= (AdjacencyList &&list)=default
 Move assignment.
 
bool operator== (const AdjacencyList &list) const
 Equality operator.
 
std::int32_t num_nodes () const
 Number of nodes. More...
 
int num_links (int node) const
 Number of connections for given node. More...
 
Eigen::Array< T, Eigen::Dynamic, 1 >::SegmentReturnType links (int node)
 Links (edges) for given node. More...
 
Eigen::Array< T, Eigen::Dynamic, 1 >::ConstSegmentReturnType links (int node) const
 Links (edges) for given node (const version) More...
 
const std::int32_t * links_ptr (int node) const
 TODO: attempt to remove.
 
const Eigen::Array< T, Eigen::Dynamic, 1 > & array () const
 Return contiguous array of links for all nodes (const version)
 
const Eigen::Array< std::int32_t, Eigen::Dynamic, 1 > & offsets () const
 Offset for each node in array() (const version)
 
std::size_t hash () const
 Hash of graph.
 
std::string str () const
 Return 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/5]

template<typename T >
dolfinx::graph::AdjacencyList< 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/5]

template<typename T >
template<typename U , typename V , std::enable_if_t< std::is_base_of< Eigen::EigenBase< std::decay_t< V >>, std::decay_t< V >>::value, int > = 0>
dolfinx::graph::AdjacencyList< T >::AdjacencyList ( U &&  data,
V &&  offsets 
)
inline

Construct adjacency list from arrays of data (Eigen data types)

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

◆ AdjacencyList() [3/5]

template<typename T >
template<typename U , typename V , std::enable_if_t<!std::is_base_of< Eigen::EigenBase< std::decay_t< V >>, std::decay_t< V >>::value, int > = 0>
dolfinx::graph::AdjacencyList< T >::AdjacencyList ( U &&  data,
V &&  offsets 
)
inline

Construct adjacency list from arrays of data (non-Eigen data types)

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

◆ AdjacencyList() [4/5]

template<typename T >
dolfinx::graph::AdjacencyList< T >::AdjacencyList ( const Eigen::Ref< const Eigen::Array< T, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor >> &  matrix)
inlineexplicit

Construct adjacency list for a problem with a fixed number of links (edges) for each node.

Parameters
[in]matrixTwo-dimensional array of adjacency data where matrix(i, j) is the jth neighbor of the ith node

◆ AdjacencyList() [5/5]

template<typename T >
template<typename X >
dolfinx::graph::AdjacencyList< T >::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]dataTODO

Member Function Documentation

◆ links() [1/2]

template<typename T >
Eigen::Array<T, Eigen::Dynamic, 1>::SegmentReturnType dolfinx::graph::AdjacencyList< T >::links ( int  node)
inline

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 >
Eigen::Array<T, Eigen::Dynamic, 1>::ConstSegmentReturnType dolfinx::graph::AdjacencyList< T >::links ( int  node) const
inline

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 dolfinx::graph::AdjacencyList< T >::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()

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

Number of nodes.

Returns
The number of nodes

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