Table of Contents

Interface IGraphDataLoader<T>

Namespace
AiDotNet.Interfaces
Assembly
AiDotNet.dll

Interface for data loaders that provide graph-structured data for graph neural networks.

public interface IGraphDataLoader<T> : IDataLoader<T>, IResettable, ICountable, IBatchIterable<GraphData<T>>

Type Parameters

T

The numeric type used for calculations, typically float or double.

Inherited Members
Extension Methods

Remarks

This interface is for loading graph-structured data where: - Nodes have features (attributes for each entity) - Edges define connections between nodes - Labels can be per-node (node classification) or per-graph (graph classification)

For Beginners: Graphs represent relationships between things:

Example: Social Network

  • Nodes: People
  • Edges: Friendships
  • Node Features: Age, interests, location
  • Task: Predict user interests based on their friends

Example: Molecular Structure

  • Nodes: Atoms
  • Edges: Chemical bonds
  • Node Features: Atom type, charge
  • Task: Predict molecular properties (toxicity, activity)

The adjacency matrix tells the GNN which nodes are connected so it can aggregate information from neighbors during message passing.

Properties

AdjacencyMatrix

Gets the adjacency matrix of shape [numNodes, numNodes].

Tensor<T> AdjacencyMatrix { get; }

Property Value

Tensor<T>

EdgeIndex

Gets the edge index tensor in COO format [numEdges, 2].

Tensor<T> EdgeIndex { get; }

Property Value

Tensor<T>

GraphLabels

Gets graph labels for graph classification tasks, or null if not available.

Tensor<T>? GraphLabels { get; }

Property Value

Tensor<T>

NodeFeatures

Gets the node feature tensor of shape [numNodes, numFeatures].

Tensor<T> NodeFeatures { get; }

Property Value

Tensor<T>

NodeLabels

Gets node labels for node classification tasks, or null if not available.

Tensor<T>? NodeLabels { get; }

Property Value

Tensor<T>

NumClasses

Gets the number of classes for classification tasks.

int NumClasses { get; }

Property Value

int

NumEdges

Gets the number of edges in the graph (or total across all graphs).

int NumEdges { get; }

Property Value

int

NumGraphs

Gets the number of graphs in the dataset (1 for single-graph datasets like citation networks).

int NumGraphs { get; }

Property Value

int

NumNodeFeatures

Gets the number of node features.

int NumNodeFeatures { get; }

Property Value

int

NumNodes

Gets the number of nodes in the graph (or total across all graphs).

int NumNodes { get; }

Property Value

int

Methods

CreateGraphClassificationTask(double, double, int?)

Creates a graph classification task for datasets with multiple graphs.

GraphClassificationTask<T> CreateGraphClassificationTask(double trainRatio = 0.8, double valRatio = 0.1, int? seed = null)

Parameters

trainRatio double
valRatio double
seed int?

Returns

GraphClassificationTask<T>

CreateLinkPredictionTask(double, double, int?)

Creates a link prediction task for predicting missing edges.

LinkPredictionTask<T> CreateLinkPredictionTask(double trainRatio = 0.85, double negativeRatio = 1, int? seed = null)

Parameters

trainRatio double
negativeRatio double
seed int?

Returns

LinkPredictionTask<T>

CreateNodeClassificationTask(double, double, int?)

Creates a node classification task with train/val/test split.

NodeClassificationTask<T> CreateNodeClassificationTask(double trainRatio = 0.1, double valRatio = 0.1, int? seed = null)

Parameters

trainRatio double
valRatio double
seed int?

Returns

NodeClassificationTask<T>