Template Numerical Library version\ main:0b2c40fb1
Loading...
Searching...
No Matches
TNL::Graphs::GraphVertexView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >, GraphType_ > Struct Template Reference

Specialization of GraphVertexView for sparse adjacency matrices. More...

#include <TNL/Graphs/GraphVertexView.h>

Inheritance diagram for TNL::Graphs::GraphVertexView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >, GraphType_ >:
[legend]
Collaboration diagram for TNL::Graphs::GraphVertexView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >, GraphType_ >:
[legend]

Public Types

using ColumnIndexesViewType = typename Base::ColumnsIndexesViewType
using ConstMatrixRowView = typename MatrixRowView::ConstRowView
using ConstMatrixView = typename MatrixView::ConstViewType
 Type of constant sparse matrix view.
using ConstVertexView = GraphVertexView< ConstMatrixView, GraphType_ >
 Type of the constant graph node view.
using IndexType
 The type used for matrix elements indexing.
using MatrixRowView
using MatrixView = Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >
 Type of the sparse matrix view.
using RealType
 The type of matrix elements.
using SegmentViewType
 Type representing matrix row format.
using ValuesViewType
 Type of container view used for storing the matrix elements values.
using VertexView = GraphVertexView< MatrixView, GraphType_ >
 Type of the graph node view.
Public Types inherited from TNL::Matrices::SparseMatrixRowView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >::SegmentsViewType::SegmentViewType, Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >::ValuesViewType, Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >::ColumnIndexesViewType >
using ColumnsIndexesViewType
 Type of container view used for storing the column indexes of the matrix elements.
using ConstColumnsIndexesViewType
 Type of constant container view used for storing the column indexes of the matrix elements.
using ConstIteratorType
 Type of constant iterator for the matrix row.
using ConstRowView
 Type of constant sparse matrix row view.
using ConstValuesViewType
 Type of constant container view used for storing the matrix elements values.
using GetValueConstResultType
using GetValueResultType
using IndexType
 The type used for matrix elements indexing.
using IteratorType
 Type of iterator for the matrix row.
using MatrixElementType
 The type of related matrix element.
using RealType
 The type of matrix elements.
using RowView
 Type of sparse matrix row view.
using SegmentViewType
 Type representing matrix row format.
using ValuesViewType
 Type of container view used for storing the matrix elements values.

Public Member Functions

__cuda_callable__ GraphVertexView (const GraphVertexView &)=default
 Copy constructor.
__cuda_callable__ GraphVertexView (const MatrixRowView &matrixRowView)
 Constructs a vertex view from a matrix row view.
__cuda_callable__ GraphVertexView (const SegmentViewType &segmentView, const ValuesViewType &valuesView, const ColumnIndexesViewType &columnIndexesView)
 Constructs a vertex view from segment, values, and column index views.
__cuda_callable__ GraphVertexView (MatrixRowView &&matrixRowView)
 Constructs a vertex view by moving from a matrix row view.
__cuda_callable__ IndexType getDegree () const
 Returns the degree (number of edges) of this vertex.
__cuda_callable__ RealTypegetEdgeWeight (IndexType edgeIndex)
 Returns the weight of the edge at the given edge index (non-const version).
__cuda_callable__ const RealTypegetEdgeWeight (IndexType edgeIndex) const
 Returns the weight of the edge at the given edge index (const version).
__cuda_callable__ IndexType getTargetIndex (IndexType edgeIndex) const
 Returns the target vertex index of the edge at the given edge index.
__cuda_callable__ IndexType getVertexIndex () const
 Returns the index of this vertex in the graph.
__cuda_callable__ void setEdge (IndexType edgeIndex, IndexType target, const RealType &weight)
 Sets both the target vertex and weight for an edge.
__cuda_callable__ void setEdgeWeight (IndexType edgeIndex, const RealType &weight)
 Sets the weight of the edge at the given edge index.
Public Member Functions inherited from TNL::Matrices::SparseMatrixRowView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >::SegmentsViewType::SegmentViewType, Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >::ValuesViewType, Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >::ColumnIndexesViewType >
__cuda_callable__ SparseMatrixRowView (SegmentViewType segmentView, ValuesViewType values, ColumnsIndexesViewType columnIndexes)
 Constructor with segmentView, values and columnIndexes.
__cuda_callable__ IteratorType begin ()
 Returns iterator pointing at the beginning of the matrix row.
__cuda_callable__ ConstIteratorType cbegin () const
 Returns constant iterator pointing at the beginning of the matrix row.
__cuda_callable__ ConstIteratorType cend () const
 Returns constant iterator pointing at the end of the matrix row.
__cuda_callable__ IteratorType end ()
 Returns iterator pointing at the end of the matrix row.
__cuda_callable__ const ColumnsIndexesViewType::ValueTypegetColumnIndex (IndexType localIdx) const
 Returns constants reference to a column index of an element with given rank in the row.
__cuda_callable__ IndexType getGlobalIndex (IndexType localIdx) const
 Computes the global index of the matrix element with given rank in the matrix row.
__cuda_callable__ IndexType getRowIndex () const
 Returns the matrix row index.
__cuda_callable__ IndexType getSize () const
 Returns size of the matrix row, i.e. number of matrix elements in this row.
__cuda_callable__ auto getValue (IndexType localIdx) const -> GetValueConstResultType
 Returns constants reference to value of an element with given rank in the row.
__cuda_callable__ bool operator== (const SparseMatrixRowView< _SegmentView, _ValuesView, _ColumnsIndexesView > &other) const
 Comparison of two matrix rows.
__cuda_callable__ void setColumnIndex (IndexType localIdx, const IndexType &columnIndex)
 Sets a column index of matrix element with given rank in the matrix row.
__cuda_callable__ void setElement (IndexType localIdx, IndexType columnIndex, const RealType &value)
 Sets both a value and a column index of matrix element with given rank in the matrix row.
__cuda_callable__ void setValue (IndexType localIdx, const RealType &value)
 Sets a value of matrix element with given rank in the matrix row.
__cuda_callable__ void sortColumnIndexes ()
 Sort the matrix row by column indexes in ascending order.

Protected Types

using Base
 Base type.

Additional Inherited Members

Static Public Member Functions inherited from TNL::Matrices::SparseMatrixRowView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >::SegmentsViewType::SegmentViewType, Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >::ValuesViewType, Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >::ColumnIndexesViewType >
static constexpr bool isBinary ()
 Tells whether the parent matrix is a binary matrix.
Protected Attributes inherited from TNL::Matrices::SparseMatrixRowView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >::SegmentsViewType::SegmentViewType, Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >::ValuesViewType, Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >::ColumnIndexesViewType >
ColumnsIndexesViewType columnIndexes
SegmentViewType segmentView
ValuesViewType values

Detailed Description

template<typename Real, typename Device, typename Index, typename MatrixType_, template< typename Device_, typename Index_ > class SegmentsView, typename ComputeRealType, typename GraphType_>
struct TNL::Graphs::GraphVertexView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >, GraphType_ >

Specialization of GraphVertexView for sparse adjacency matrices.

This specialization is used when the graph stores its adjacency information using a sparse matrix. In this case, only the actual edges are stored, and edge indices are separate from target vertex indices. The sparse representation is more memory-efficient for graphs with few edges per vertex.

Template Parameters
RealType of edge weights.
DeviceDevice type (Host or Cuda).
IndexType for indexing vertices and edges.
MatrixType_Matrix type for the sparse matrix.
SegmentsViewSegments view type for the sparse matrix.
ComputeRealTypeComputation real type.
GraphType_Graph type for orientation information.

Member Typedef Documentation

◆ Base

template<typename Real, typename Device, typename Index, typename MatrixType_, template< typename Device_, typename Index_ > class SegmentsView, typename ComputeRealType, typename GraphType_>
using TNL::Graphs::GraphVertexView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >, GraphType_ >::Base
protected
Initial value:
SegmentViewType,
ColumnIndexesViewType >
RowView is a simple structure for accessing rows of sparse matrix.
Definition SparseMatrixRowView.h:29

Base type.

◆ MatrixRowView

template<typename Real, typename Device, typename Index, typename MatrixType_, template< typename Device_, typename Index_ > class SegmentsView, typename ComputeRealType, typename GraphType_>
using TNL::Graphs::GraphVertexView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >, GraphType_ >::MatrixRowView
Initial value:
typename MatrixView::SegmentsViewType::SegmentViewType,
Containers::VectorView< typename TNL::copy_const< Index >::template from< Real >::type, Device, Index > ColumnIndexesViewType
Type of the container view for matrix element column indexes.
Definition SparseMatrixBase.h:56

Constructor & Destructor Documentation

◆ GraphVertexView() [1/3]

template<typename Real, typename Device, typename Index, typename MatrixType_, template< typename Device_, typename Index_ > class SegmentsView, typename ComputeRealType, typename GraphType_>
__cuda_callable__ TNL::Graphs::GraphVertexView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >, GraphType_ >::GraphVertexView ( const SegmentViewType & segmentView,
const ValuesViewType & valuesView,
const ColumnIndexesViewType & columnIndexesView )
inline

Constructs a vertex view from segment, values, and column index views.

Parameters
segmentViewView of the matrix segment (row metadata).
valuesViewView of edge weights.
columnIndexesViewView of target vertex indices.

◆ GraphVertexView() [2/3]

template<typename Real, typename Device, typename Index, typename MatrixType_, template< typename Device_, typename Index_ > class SegmentsView, typename ComputeRealType, typename GraphType_>
__cuda_callable__ TNL::Graphs::GraphVertexView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >, GraphType_ >::GraphVertexView ( MatrixRowView && matrixRowView)
inline

Constructs a vertex view by moving from a matrix row view.

Parameters
matrixRowViewMatrix row view to move from.

◆ GraphVertexView() [3/3]

template<typename Real, typename Device, typename Index, typename MatrixType_, template< typename Device_, typename Index_ > class SegmentsView, typename ComputeRealType, typename GraphType_>
__cuda_callable__ TNL::Graphs::GraphVertexView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >, GraphType_ >::GraphVertexView ( const MatrixRowView & matrixRowView)
inline

Constructs a vertex view from a matrix row view.

Parameters
matrixRowViewMatrix row view to copy from.

Member Function Documentation

◆ getDegree()

template<typename Real, typename Device, typename Index, typename MatrixType_, template< typename Device_, typename Index_ > class SegmentsView, typename ComputeRealType, typename GraphType_>
__cuda_callable__ IndexType TNL::Graphs::GraphVertexView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >, GraphType_ >::getDegree ( ) const
inlinenodiscard

Returns the degree (number of edges) of this vertex.

For sparse matrices, this counts only the valid edges (excluding padding entries). Padding entries are marked with paddingIndex and are not counted as real edges.

Returns
The vertex degree.

◆ getEdgeWeight() [1/2]

template<typename Real, typename Device, typename Index, typename MatrixType_, template< typename Device_, typename Index_ > class SegmentsView, typename ComputeRealType, typename GraphType_>
__cuda_callable__ RealType & TNL::Graphs::GraphVertexView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >, GraphType_ >::getEdgeWeight ( IndexType edgeIndex)
inlinenodiscard

Returns the weight of the edge at the given edge index (non-const version).

Parameters
edgeIndexIndex of the edge (0 to getDegree()-1).
Returns
Reference to the edge weight.

◆ getEdgeWeight() [2/2]

template<typename Real, typename Device, typename Index, typename MatrixType_, template< typename Device_, typename Index_ > class SegmentsView, typename ComputeRealType, typename GraphType_>
__cuda_callable__ const RealType & TNL::Graphs::GraphVertexView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >, GraphType_ >::getEdgeWeight ( IndexType edgeIndex) const
inlinenodiscard

Returns the weight of the edge at the given edge index (const version).

Parameters
edgeIndexIndex of the edge (0 to getDegree()-1).
Returns
Const reference to the edge weight.

◆ getTargetIndex()

template<typename Real, typename Device, typename Index, typename MatrixType_, template< typename Device_, typename Index_ > class SegmentsView, typename ComputeRealType, typename GraphType_>
__cuda_callable__ IndexType TNL::Graphs::GraphVertexView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >, GraphType_ >::getTargetIndex ( IndexType edgeIndex) const
inlinenodiscard

Returns the target vertex index of the edge at the given edge index.

Parameters
edgeIndexIndex of the edge (0 to getDegree()-1).
Returns
Index of the target vertex.

◆ getVertexIndex()

template<typename Real, typename Device, typename Index, typename MatrixType_, template< typename Device_, typename Index_ > class SegmentsView, typename ComputeRealType, typename GraphType_>
__cuda_callable__ IndexType TNL::Graphs::GraphVertexView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >, GraphType_ >::getVertexIndex ( ) const
inlinenodiscard

Returns the index of this vertex in the graph.

Returns
The vertex index.

◆ setEdge()

template<typename Real, typename Device, typename Index, typename MatrixType_, template< typename Device_, typename Index_ > class SegmentsView, typename ComputeRealType, typename GraphType_>
__cuda_callable__ void TNL::Graphs::GraphVertexView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >, GraphType_ >::setEdge ( IndexType edgeIndex,
IndexType target,
const RealType & weight )
inline

Sets both the target vertex and weight for an edge.

For sparse matrices, this method updates both the target vertex index and the edge weight at the specified edge index.

Parameters
edgeIndexIndex of the edge (0 to getDegree()-1).
targetNew target vertex index.
weightNew weight for the edge.

◆ setEdgeWeight()

template<typename Real, typename Device, typename Index, typename MatrixType_, template< typename Device_, typename Index_ > class SegmentsView, typename ComputeRealType, typename GraphType_>
__cuda_callable__ void TNL::Graphs::GraphVertexView< Matrices::SparseMatrixView< Real, Device, Index, MatrixType_, SegmentsView, ComputeRealType >, GraphType_ >::setEdgeWeight ( IndexType edgeIndex,
const RealType & weight )
inline

Sets the weight of the edge at the given edge index.

Parameters
edgeIndexIndex of the edge (0 to getDegree()-1).
weightNew weight for the edge.

The documentation for this struct was generated from the following file: