Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

graph
data structures
undirected graph
directed graph

Directed Graphs vs. Undirected Graphs

Educative Answers Team

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:

svg viewer
Directed Graph
svg viewer
Undirected Graph

RELATED TAGS

graph
data structures
undirected graph
directed graph
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring