GraphData<T>
Models & Types · AiDotNet.Data.Structures
Represents a single graph with nodes, edges, features, and optional labels.
For Beginners
Think of a graph as a social network:
- Nodes: People in the network
- Edges: Friendships or connections between people
- Node Features: Each person’s attributes (age, interests, etc.)
- Edge Features: Relationship attributes (how long they’ve been friends, interaction frequency)
- Labels: What we want to predict (e.g., will this person like a product?)
This class packages all this information together for graph neural network training.
How It Works
GraphData encapsulates all information about a graph structure including:
- Node features (attributes for each node)
- Edge indices (connections between nodes)
- Edge features (optional attributes for edges)
- Adjacency matrix (graph structure in matrix form)
- Labels (for supervised learning tasks)
Constructors
| Constructor | Summary |
|---|---|
GraphData() |
Properties
| Property | Summary |
|---|---|
Dictionary<string, object> Metadata { get; set; } |
Metadata for heterogeneous graphs (optional). |
Tensor<T> AdjacencyMatrix { get; set; } |
Adjacency matrix of shape [num_nodes, num_nodes] or [batch_size, num_nodes, num_nodes]. |
Tensor<T> EdgeFeatures { get; set; } |
Optional edge feature matrix of shape [num_edges, num_edge_features]. |
Tensor<T> EdgeIndex { get; set; } |
Edge index tensor of shape [2, num_edges] or [num_edges, 2]. |
Tensor<T> GraphLabel { get; set; } |
Graph-level label for graph-level tasks (e.g., graph classification). |
Tensor<T> NodeFeatures { get; set; } |
Node feature matrix of shape [num_nodes, num_features]. |
Tensor<T> NodeLabels { get; set; } |
Node labels for node-level tasks (e.g., node classification). |
Tensor<T> TestMask { get; set; } |
Mask indicating which nodes are in the test set. |
Tensor<T> TrainMask { get; set; } |
Mask indicating which nodes are in the training set. |
Tensor<T> ValMask { get; set; } |
Mask indicating which nodes are in the validation set. |
int NumEdgeFeatures { get; } |
Number of edge features (0 if no edge features). |
int NumEdges { get; } |
Number of edges in the graph. |
int NumNodeFeatures { get; } |
Number of node features. |
int NumNodes { get; } |
Number of nodes in the graph. |