name: graph-data-loading
description: "Guides StellarGraph graph construction, graph queries, data-format
validation, built-in dataset loaders, and safe tiny graph smoke checks."
disable-model-invocation: true
metadata:
disco-role: operating
license: Apache 2.0
Graph Data Loading
Use this sub-skill when a StellarGraph task starts with raw graph data,
StellarGraph/StellarDiGraph construction, graph conversion, feature/type
validation, or built-in dataset loading.
Read first
references/data-formats.md for self-contained
Pandas, NumPy, IndexedArray, heterogeneous, directed, weighted, and NetworkX
construction patterns.
references/api-reference.md for verified
constructor signatures, query/conversion methods, and graph readiness checks.
references/datasets.md for dataset loader classes,
cache behavior, download boundaries, and load return shapes.
references/troubleshooting.md when graph
constructors reject columns, IDs, types, missing nodes, duplicate IDs, or
feature shapes.
scripts/stellargraph_data_smoke.py for
a safe local smoke that constructs tiny graphs and inspects dataset classes
without downloading data.
Route here when the user asks to
- load graph data from Pandas DataFrames, NumPy arrays,
IndexedArray, or
NetworkX;
- decide between
StellarGraph and StellarDiGraph;
- represent homogeneous vs heterogeneous graphs, multiple edge types, edge
weights, node features, edge features, or type columns;
- inspect graph summaries with
info, number_of_nodes, number_of_edges,
node_feature_sizes, edge_feature_sizes, nodes, edges, neighbors,
or adjacency conversion;
- use dataset loaders such as
Cora, CiteSeer, MovieLens, MUTAG, WN18,
or METR_LA;
- diagnose dataset cache/download issues or
STELLARGRAPH_DATASETS_PATH.
Route elsewhere
Operating workflow
- Identify graph directionality and heterogeneity before writing model code:
homogeneous vs heterogeneous, directed vs undirected, one edge type vs many,
weighted vs unweighted.
- Choose the input representation:
- Pandas DataFrame for readable IDs, columns, types, and features;
IndexedArray for compact numeric features with explicit IDs;
- NumPy arrays only when node IDs are
0, 1, 2, ...;
- NetworkX conversion when a graph object already exists and attributes are
named consistently.
- Build edge data with
source and target columns unless using custom column
names in the constructor. Add weight for weighted edges and an edge type
column or edge-type dictionary for multiple relation types.
- Build node features as numeric rows indexed by node ID. For multiple node
types, use a dictionary keyed by node type; IDs must be unique across types.
- Construct
StellarGraph(...) for undirected workflows or
StellarDiGraph(...) for directed workflows.
- Validate with small graph queries before using generators or models:
number_of_nodes, number_of_edges, node_feature_sizes, edge_types,
node_types, info(), and check_graph_for_ml() when appropriate.
- Only after the graph object is valid, move to the generator/model sub-skill
that owns the downstream task.
Dataset workflow
- Instantiate the dataset class; do not call
download() unless the user
wants network access.
- Set
STELLARGRAPH_DATASETS_PATH to a writable cache when the default user
cache is unsuitable.
- Use each loader's
load(...) signature rather than assuming every dataset
returns the same tuple shape.
- Convert labels or targets with scikit-learn/Pandas before model fitting.
Safe checks
Run the bundled smoke from any environment with StellarGraph installed:
python sub-skills/graph-data-loading/scripts/stellargraph_data_smoke.py --help
python sub-skills/graph-data-loading/scripts/stellargraph_data_smoke.py
Add --repo-root PATH only when intentionally testing an uninstalled local
checkout. The script does not download datasets.
Quality guardrails
- Do not infer node features from non-numeric label columns; encode labels
separately for supervised workflows.
- Do not reuse the same external node ID across different node types; disambiguate
IDs before construction.
- Do not pass edge endpoints that are missing from explicit
nodes unless you
intentionally want node inference from edges.
- Do not keep model code in this sub-skill; it should produce a valid graph
object and then route to the correct generator/model route.