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

















