liveBook · Manning

Edge

As explained in Knowledge Graphs and LLMs in Action

A relationship, or edge, is a graph connection representing a meaningful association between nodes.

An edge is a graph connection between nodes that represents a meaningful association. In knowledge graphs, edges connect entities such as diseases and symptoms, people and organizations, or genes and proteins; edge properties add relevant context. section 1.1

Edges support several implementation patterns:

  • Represent semantic relations extracted from text, such as WORKS_FOR between a person and an organization. Choose a consistent direction and naming convention across documents. section 5.2.2
  • Model undirected connections when association has no stated direction, as in a people network used for fraud analysis. section 10.1
  • Control execution flow in directed agent workflows, including branches whose next edge is resolved dynamically from earlier results. section 15.1

Healthcare knowledge graph

A healthcare graph can connect a disease to its symptoms, a drug to a disease, or a gene to a protein. These explicit connections allow systems to traverse related information and support reasoning across multiple entities. section 1.1

Listing 10.1 Creating the fraud detection network example
import networkx as nx
import matplotlib.pyplot as plt

def create_fraud_network():
    G = nx.Graph()   #1

    fraudsters = ['D', 'E', 'F', 'I']   #2

    # Add all nodes first
    nodes = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
             'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T']   #3

    G.add_nodes_from(nodes)

    for node in G.nodes():
        G.nodes[node]['is_fraudster'] = node in fraudsters   #4

    edges = [ 
            ('A', 'B'), ('A', 'G'), ('A', 'H'), ('A', 'I'), ('A', 'O'),
            ('A', 'T'), ('B', 'D'), ('B', 'C'), ('D', 'E'), ('D', 'F'),
            ('D', 'G'), ('E', 'F'), ('F', 'G'), ('G', 'I'), ('H', 'K'),
            ('I', 'K'), ('I', 'N'), ('K', 'J'), ('L', 'M'), ('L', 'N'),
            ('N', 'M'), ('O', 'P'), ('O', 'Q'), ('Q', 'R'), ('Q', 'S') 
    ]   #5

    G.add_edges_from(edges)

    return G   #6

The fraud-network listing shows edges as node pairs added to a NetworkX graph, providing a concrete representation for subsequent graph analysis. section 10.1

How Knowledge Graphs and LLMs in Action covers it

How deep it goes
Explains semantic direction, undirected modeling, properties, and dynamic routing, but does not develop edge algorithms independently.
Examples
Uses healthcare entity associations, Jane Austen–WORKS_FOR–Google, a NetworkX fraud network, and LangGraph agent routing.
What you can do after
Build graph connections in NetworkX, model extracted relations consistently, or configure execution paths in LangGraph.
How it connects
Links nodes, properties, knowledge graphs, relation extraction, graph analysis, and directed workflow execution.

Also explained in

Compare how 18 books explain edge →

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.