![]() |
Vulpes
0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
|
Graph wrapper with Torch tensors for features and edges. More...
#include <gnn_graph.hpp>
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 |
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.
| using vulpes::geometry::GNNGraph::float_t = float |
| using vulpes::geometry::GNNGraph::index_t = int64_t |
| using vulpes::geometry::GNNGraph::IndVec = std::vector<index_t> |
|
default |
|
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.
| IndexType | Integral type of the input map (e.g., int32_t/int64_t). |
| feature_tensor | Node features with shape [num_nodes, num_features] and dtype tensor_float_t. |
| dual_map | Dual graph in CRS form (any integral IndexType). |
|
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.
|
inline |
|
inline |
|
inline |
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).
| subset_idxs | Node ids to keep (global indices). |
GNNGraph restricted to the subset.
|
private |
|
private |
Dual-graph adjacency (CRS).
|
private |
Edge list [2, nnz] (COO, int64).
|
private |
Node features [N, F].
|
private |
Number of features per node.
|
private |
Number of nodes.
|
inlinestaticconstexpr |
|
inlinestaticconstexpr |