Directed Graphs vs. Undirected Graphs

Directed Graphs

A directed graph is a set of vertices (nodes) connected by edges, with each node having a direction associated with it.

Edges are usually represented by arrows pointing in the direction the graph can be traversed.

In the example on the right, the graph can be traversed from vertex A to B, but not from vertex B to A.

svg viewer

Undirected Graphs

In an undirected graph the edges are bidirectional, with no direction associated with them. Hence, the graph can be traversed in either direction. The absence of an arrow tells us that the graph is undirected.

svg viewer

In the example on the left, the graph can be traversed from node A to B as well as from node B to A.

Some more complex directed and undirected graphs might look like the following:

Directed Graph
Directed Graph
Undirected Graph
Undirected Graph

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved