A directed graph has edges with direction. An undirected graph has edges that can be used both ways.
This distinction changes reachability, traversal, cycle detection, and ordering.
Core Idea
In a directed graph, an edge from A to B does not automatically mean there is an edge from B to A. In an undirected graph, the connection works both ways.
Direction usually comes from the problem meaning. A one-way road, dependency, or web link is directed. A mutual friendship or two-way road is often undirected.
Python Example
directed = {
"A": ["B"],
"B": [],
}
undirected = {
"A": ["B"],
"B": ["A"],
}The undirected version stores the connection in both adjacency lists.
Common Confusions
Do not add the reverse edge in a directed graph unless the problem says movement is allowed both ways.
Do not forget the reverse edge in an undirected graph when building an adjacency list. Missing one direction changes the graph.
When To Use It
Use directed edges for one-way relationships and prerequisite-like structure. Use undirected edges for symmetric relationships where either endpoint can reach the other through the same edge.