Loading...
Searching...
No Matches
AdjacencyList< LinkData, NodeData > Class Template Reference

This class provides a static adjacency list data structure. More...

`#include <AdjacencyList.h>`

## Public Types

using | link_type = LinkData
| Adjacency list link (edge) type.
using | node_data_type = NodeData
| Adjacency list node data type.

## 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<LinkData>> 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 link (edge) data and offsets.
template<typename U, typename V, typename W> requires std::is_convertible_v<std::remove_cvref_t<U>, std::vector<LinkData>> and std::is_convertible_v<std::remove_cvref_t<V>, std::vector<std::int32_t>> and std::is_convertible_v<std::remove_cvref_t<W>, std::vector<NodeData>>
| AdjacencyList (U &&data, V &&offsets, W &&node_data)
| Construct adjacency list from arrays of link (edge) data, offsets, and node data.
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.
AdjacencyList & | operator= (const AdjacencyList &list)=default
| Assignment operator.
AdjacencyList & | operator= (AdjacencyList &&list)=default
| Move assignment operator.
bool | operator== (const AdjacencyList &list) const
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< LinkData > | links (std::size_t node)
| Get the links (edges) for given node.
std::span< const LinkData > | links (std::size_t node) const
| Get the links (edges) for given node (const version).
const std::vector< LinkData > & | array () const
| Return contiguous array of links for all nodes (const version).
std::vector< LinkData > & | 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().
const std::optional< std::vector< NodeData > > & | node_data () const
std::optional< std::vector< NodeData > > & | node_data ()
std::string | str () const
| Informal string representation (pretty-print).

## Detailed Description

template<typename LinkData, typename NodeData = std::nullptr_t>
class dolfinx::graph::AdjacencyList< LinkData, NodeData >

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.

The link (edge) type is template parameter, which allows link data to be stored, e.g. a pair with the target node index and the link weight.

Node data can also be stored.

Template Parameters

  LinkData_t | Graph link (edge) type.
  NodeData_t | Data type for graph node data.

## Constructor & Destructor Documentation

## AdjacencyList() [1/4]

template<typename LinkData, typename NodeData = std::nullptr_t>

AdjacencyList | ( | const std::int32_t | n | ) |

inline explicit

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

Parameters

  [in] | n | Number of nodes.

## AdjacencyList() [2/4]

template<typename LinkData, typename NodeData = std::nullptr_t>
template<typename U, typename V>
requires std::is_convertible_v<std::remove_cvref_t<U>, std::vector<LinkData>> 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 link (edge) data and offsets.

Parameters

  [in] | data | Adjacency lost data array.
  [in] | offsets | Offsets into data for each node, where offsets[i] is the first index in data for node i. The last index in offsets is the equal to the length of data. array for node i.

## AdjacencyList() [3/4]

template<typename LinkData, typename NodeData = std::nullptr_t>
template<typename U, typename V, typename W>
requires std::is_convertible_v<std::remove_cvref_t<U>, std::vector<LinkData>> and std::is_convertible_v<std::remove_cvref_t<V>, std::vector<std::int32_t>> and std::is_convertible_v<std::remove_cvref_t<W>, std::vector<NodeData>>

AdjacencyList | ( | U && | data,
|  | V && | offsets,
|  | W && | node_data )

inline

Construct adjacency list from arrays of link (edge) data, offsets, and node data.

Parameters

  [in] | data | Adjacency lost data array.
  [in] | offsets | Offsets into data for each node, where offsets[i] is the first index in data for node i. The last index in offsets is the equal to the length of data.
  [in] | node_data | Node data array where node_data[i] is the data attached to node i.

## AdjacencyList() [4/4]

template<typename LinkData, typename NodeData = std::nullptr_t>
template<typename X>

AdjacencyList | ( | const std::vector< X > & | data | ) |

inline explicit

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] | data | Adjacency list data, where std::next(data, i) points to the container of links (edges) for node i.

## Member Function Documentation

## links() [1/2]

template<typename LinkData, typename NodeData = std::nullptr_t>

std::span< LinkData > links | ( | std::size_t | node | ) |

inline

Get the links (edges) for given node.

Parameters

  [in] | node | Node index.

Returns
  Array of outgoing links for the node. The length will be AdjacencyList::num_links(node).

## links() [2/2]

template<typename LinkData, typename NodeData = std::nullptr_t>

std::span< const LinkData > links | ( | std::size_t | node | ) | const

inline

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

Parameters

  [in] | node | Node index.

Returns
  Array of outgoing links for the node. The length will be AdjacencyList:num_links(node).

## node_data() [1/2]

template<typename LinkData, typename NodeData = std::nullptr_t>

std::optional< std::vector< NodeData > > & node_data | ( |  | ) |

inline

Return node data (if present), where node_data()[i] is the data for node i.

## node_data() [2/2]

template<typename LinkData, typename NodeData = std::nullptr_t>

const std::optional< std::vector< NodeData > > & node_data | ( |  | ) | const

inline

Return node data (if present), where node_data()[i] is the data for node i (const version).

## num_links()

template<typename LinkData, typename NodeData = std::nullptr_t>

int num_links | ( | std::size_t | node | ) | const

inline

Number of connections for given node.

Parameters

  [in] | node | Node index.

Returns
  The number of outgoing links (edges) from the node.

## num_nodes()

template<typename LinkData, typename NodeData = std::nullptr_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 LinkData, typename NodeData = std::nullptr_t>

bool operator== | ( | const AdjacencyList< LinkData, NodeData > & | list | ) | const

inline

Equality operator

Returns
  True is the adjacency lists are equal

## str()

template<typename LinkData, typename NodeData = std::nullptr_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 file:

- /build/fenics-dolfinx-Vk5o25/fenics-dolfinx-0.10.0.post5/cpp/dolfinx/graph/AdjacencyList.h