liveBook · Manning

Ego network

As explained in Knowledge Graphs and LLMs in Action

An ego network is a graph consisting of a focal node and its immediate neighboring nodes and connections.

An ego network, or egonet, contains a focal node and its immediate neighbors. The focal node is the ego; surrounding nodes are alters. In graph feature engineering, this one-hop structure supplies local node features before broader network measures are considered. section 10.1

Use an ego network to derive progressively richer structural signals:

  • Count the ego’s neighbors and inspect connections among them. section 10.1
  • Count triangles involving the ego; classify them as fraudulent, legitimate, or semifraudulent when node labels are available. section 10.1.2
  • Compute egonet density as observed internal edges divided by the maximum possible edges. section 10.1.3
  • Aggregate local values recursively with ReFeX to capture increasingly distant structural context. section 10.3.1

Node A in a fraud-detection graph

Node A connects to B, G, H, I, O, and T, producing a seven-node egonet. It contains seven internal edges, nine edges leaving the egonet, density about 0.33, and recursive ReFeX values including neighbor-degree sum 17 and second-iteration sum 69. section 10.1.3 section 10.3.1

Table 10.10 Details of the egonet structure for the nodes in figure 10.9
Node’s egonet
# of nodes
# of internal edges
# of in/out edges
A
7
7
9
B
4
3
5
C
2
1
1
D
5
6
4
E
3
3
3
…
…
…
…

Inspect the node-by-node table of egonet size, internal edges, and edges connecting the egonet outward. section 10.3.1

How Knowledge Graphs and LLMs in Action covers it

How deep it goes
Defines ego and alters, implements triangles and density, then extends locality through recursive ReFeX aggregation.
Examples
Demonstrates fraud-network nodes through triangle categories, density values, egonet edge counts, and ReFeX iterations for node A.
What it assumes
Assumes basic graphs, nodes, edges, and supervised labels; teaches ego, alters, internal edges, and neighborhood aggregation concretely.
What you can do after
Apply it via NetworkX to calculate neighborhood, triangle, density, and recursive structural features for graph nodes.
How it connects
Connects node features with triangles, graph density, fraud detection, and ReFeX, while contrasting local and global metrics.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Knowledge Graphs and LLMs in Action. The section links point to the parts of the book it draws on.