Template Numerical Library version\ main:4e6e2c1
Loading...
Searching...
No Matches
Graph Traversal Lambda Functions Reference

This page documents the lambda function signatures used in graph traversal operations.

Traversal Function (Non-Const Graph)

For non-const graphs with sparse adjacency matrix (Matrices::SparseMatrix), the traversal function has full access to modify edge indices and weights:

auto function = [=] __cuda_callable__ ( IndexType sourceIdx, IndexType localIdx, IndexType& targetIdx, RealType& weight ) {
... }
#define __cuda_callable__
Definition Macros.h:49

Parameters:

  • sourceIdx - The index of the graph vertex to which the edge belongs
  • localIdx - The rank/position of the edge within the graph vertex (0-based)
  • targetIdx - Reference to the target vertex index (can be modified)
  • weight - Reference to the edge weight (can be modified)

For other types of adjacent matrices like dense (TNL::Matrices::DenseMatrix ), tridiagonal matrices (TNL::Matrices::TridiagonalMatrix) or multidiagonal (TNL::Matrices::MultidiagonalMatrix), the index of the target vertex is defined implicitly and cannot be changed even for non-constant graphss. The signature then reads as:

auto function = [=] __cuda_callable__ ( IndexType sourceIdx, IndexType localIdx, IndexType targetIdx, RealType& weight ) {
... }

Parameters:

  • sourceIdx - The index of the graph vertex to which the edge belongs
  • localIdx - The rank/position of the edge within the graph vertex (0-based)
  • targetIdx - The index of the target vertex
  • weight - Reference to the edge weight (can be modified)

Traversal Function (Const Graph)

For constant graphs, the traversal function has read-only access:

auto function = [=] __cuda_callable__ ( IndexType sourceIdx, IndexType localIdx, IndexType targetIdx, const RealType& weight
) {
... }

Parameters:

  • sourceIdx - The index of the graph vertex to which the edge belongs
  • localIdx - The rank/position of the edge within the graph vertex (0-based)
  • targetIdx - The index of the target vertex (read-only)
  • weight - Const reference to the edge weight (read-only)

Vertex Traversal Function (Non-Const Graph)

When traversing particular vertices with vertex-level operations, the function receives the vertex index:

auto function = [=] __cuda_callable__ ( typename Graph::VertexView vertex ) { ... }
GraphVertexView< AdjacencyMatrixView, Orientation > VertexView
Type of the graph nodes view.
Definition Graph.h:90

Parameters:

  • vertex - The view of graph vertex being processed

Vertex Traversal Function (Const Graph)

Same signature for const graphs:

auto function = [=] __cuda_callable__ ( typename Graph::ConstVertexView vertex ) { ... }
typename VertexView::ConstVertexView ConstVertexView
Type of constant graph nodes view.
Definition Graph.h:93

Parameters:

  • vertex - The constant view of graph vertex being processed

Condition Lambda

For conditional traversal operations (forEdgesIf, forVerticesIf), a condition function determines which vertices to process:

auto condition = [=] __cuda_callable__ ( IndexType vertexIdx ) -> bool { ... }

Parameters:

  • vertexIdx - The index of the graph vertex to check

Returns:

  • true if the vertex should be processed, false to skip it

Related Pages