What is the difference between a directed graph and an undirected graph?

Algorithm Design Questions



49 Short 51 Medium 39 Long Answer Questions Question Index

What is the difference between a directed graph and an undirected graph?

The main difference between a directed graph and an undirected graph lies in the presence or absence of directionality in the edges connecting the vertices.

In a directed graph, also known as a digraph, the edges have a specific direction associated with them. This means that the relationship between two vertices is one-way, and the edge connecting them has an arrow indicating the direction of the relationship. For example, if vertex A is connected to vertex B with a directed edge, it means that there is a directed path from A to B, but not necessarily from B to A.

On the other hand, an undirected graph does not have any directionality in its edges. The relationships between vertices are bidirectional, and the edges connecting them do not have any arrows. If vertex A is connected to vertex B with an undirected edge, it means that there is a path between A and B in both directions.

In summary, the key distinction between a directed graph and an undirected graph is the presence or absence of directionality in the edges, determining whether the relationships between vertices are one-way or bidirectional.