Egonets
The standard pipeline produces one embedding per graph. For node-level problems —
like flagging anomalous nodes — NEExT decomposes each graph into one subgraph per node,
called an egonet. Running the usual feature → embedding pipeline on that
EgonetCollection then yields one embedding per node, where each embedding represents
that node’s neighborhood.
k-hop egonets
compute_k_hop_egonets extracts each node’s k-hop neighborhood as its own graph.
egonets = nxt.compute_k_hop_egonets(
graph_collection=graphs,
k_hop=2,
egonet_feature_target="is_outlier", # node attribute to carry as the egonet label
)
# From here it's the normal pipeline — but each row is now a node.
features = nxt.compute_node_features(egonets, feature_list=["all"])
embeddings = nxt.compute_graph_embeddings(
egonets, features, embedding_algorithm="approx_wasserstein", embedding_dimension=16,
) | Parameter | Default | Meaning |
|---|---|---|
k_hop | 1 | Number of hops in each node’s neighborhood |
egonet_feature_target | None | Node attribute to use as the egonet’s label |
skip_features | None | Node features to exclude from egonets |
nodes_to_sample | None | Dict mapping graph_id → node IDs to always include |
sample_fraction | 1.0 | Fraction of nodes to build egonets for |
random_seed | 13 | Seed for node sampling |
egonet_feature_targetlets each egonet inherit a per-node label (e.g."is_outlier") so you can train a model on node-level targets — the anomaly-detection preset marks nodes withis_outlier.
Leiden community egonets
Instead of fixed-radius neighborhoods, compute_leiden_egonets builds egonets from
communities found by the Leiden algorithm. This requires the iGraph backend (load with
graph_type="igraph").
graphs = nxt.read_from_csv(
edges_path="edges.csv",
node_graph_mapping_path="node_graph_mapping.csv",
graph_type="igraph",
)
egonets = nxt.compute_leiden_egonets(
graph_collection=graphs,
n_iterations=10,
resolution=1.0,
) | Parameter | Default | Meaning |
|---|---|---|
egonet_feature_target | None | Node attribute to use as the egonet’s label |
skip_features | None | Node features to exclude from egonets |
n_iterations | 10 | Leiden iterations |
resolution | 1.0 | Leiden resolution (higher → more, smaller communities) |
Both methods return an EgonetCollection, which behaves like a
GraphCollection for every downstream step.