Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
vulpes::geometry::GNNGraph Class Reference

Graph wrapper with Torch tensors for features and edges. More...

#include <gnn_graph.hpp>

Collaboration diagram for vulpes::geometry::GNNGraph:
[legend]

Public Types

using float_t = float
using index_t = int64_t
using IndVec = std::vector<index_t>
using IndMap = datastructure::CrsMap<index_t, index_t>

Public Member Functions

 GNNGraph ()=default
template<typename IndexType>
 GNNGraph (const torch::Tensor &feature_tensor, const datastructure::CrsMap< IndexType, IndexType > &dual_map)
 Construct from feature tensor and (typed) dual graph.
GNNGraph getSubGraph (const IndVec &subset_idxs)
 Induced subgraph on a set of node indices.
const auto & getFeatureTensor () const
const auto & getEdgeIndexTensor () const
const auto & getDualMap () const

Static Public Attributes

static constexpr auto tensor_index_t = torch::kInt64
static constexpr auto tensor_float_t = torch::kFloat32

Private Member Functions

void buildEdgeTensor ()
 Build the Torch COO edge tensor from the CRS map.

Private Attributes

IndMap m_dual_map
 Dual-graph adjacency (CRS).
torch::Tensor m_feature_tensor
 Node features [N, F].
index_t m_n_nodes = -1
 Number of nodes.
index_t m_n_features = -1
 Number of features per node.
torch::Tensor m_edge_index
 Edge list [2, nnz] (COO, int64).
std::vector< IndVec > m_connected_components

Detailed Description

Graph wrapper with Torch tensors for features and edges.

Assumes SAGEConv-compatible dtypes (float32 features, int64 indices). The topology is stored as a compressed sparse row map (CRS), and a 2 x nnz edge_index tensor is built for Torch models.

Member Typedef Documentation

◆ float_t

◆ index_t

◆ IndMap

◆ IndVec

Constructor & Destructor Documentation

◆ GNNGraph() [1/2]

vulpes::geometry::GNNGraph::GNNGraph ( )
default

◆ GNNGraph() [2/2]

template<typename IndexType>
vulpes::geometry::GNNGraph::GNNGraph ( const torch::Tensor & feature_tensor,
const datastructure::CrsMap< IndexType, IndexType > & dual_map )
inline

Construct from feature tensor and (typed) dual graph.

Copies/casts the input CRS map to index_t and verifies basic consistency, then builds the Torch edge_index tensor.

Template Parameters
IndexTypeIntegral type of the input map (e.g., int32_t/int64_t).
Parameters
feature_tensorNode features with shape [num_nodes, num_features] and dtype tensor_float_t.
dual_mapDual graph in CRS form (any integral IndexType).
Precondition
feature_tensor.dtype() == tensor_float_t.
feature_tensor.size(0) == dual_map.size() (nodes count).

Member Function Documentation

◆ buildEdgeTensor()

void vulpes::geometry::GNNGraph::buildEdgeTensor ( )
private

Build the Torch COO edge tensor from the CRS map.

Produces a 2 x nnz int64 tensor listing directed edges (u,v). Implementations typically expand the CSR rows and, if needed, symmetrize the adjacency to match the GNN's expectations.

◆ getDualMap()

const auto & vulpes::geometry::GNNGraph::getDualMap ( ) const
inline

◆ getEdgeIndexTensor()

const auto & vulpes::geometry::GNNGraph::getEdgeIndexTensor ( ) const
inline

◆ getFeatureTensor()

const auto & vulpes::geometry::GNNGraph::getFeatureTensor ( ) const
inline

◆ getSubGraph()

GNNGraph vulpes::geometry::GNNGraph::getSubGraph ( const IndVec & subset_idxs)

Induced subgraph on a set of node indices.

Builds a new GNNGraph containing only nodes in subset_idxs, with features row-selected, edges filtered to pairs fully inside the subset, and node ids reindexed densely from 0..m-1 (preserving the order of subset_idxs).

Parameters
subset_idxsNode ids to keep (global indices).
Returns
A new GNNGraph restricted to the subset.

Member Data Documentation

◆ m_connected_components

std::vector<IndVec> vulpes::geometry::GNNGraph::m_connected_components
private

◆ m_dual_map

IndMap vulpes::geometry::GNNGraph::m_dual_map
private

Dual-graph adjacency (CRS).

◆ m_edge_index

torch::Tensor vulpes::geometry::GNNGraph::m_edge_index
private

Edge list [2, nnz] (COO, int64).

◆ m_feature_tensor

torch::Tensor vulpes::geometry::GNNGraph::m_feature_tensor
private

Node features [N, F].

◆ m_n_features

index_t vulpes::geometry::GNNGraph::m_n_features = -1
private

Number of features per node.

◆ m_n_nodes

index_t vulpes::geometry::GNNGraph::m_n_nodes = -1
private

Number of nodes.

◆ tensor_float_t

auto vulpes::geometry::GNNGraph::tensor_float_t = torch::kFloat32
inlinestaticconstexpr

◆ tensor_index_t

auto vulpes::geometry::GNNGraph::tensor_index_t = torch::kInt64
inlinestaticconstexpr

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