What Are Vertex Edge and Path in Graph Data Structure?


Larry Thompson

In graph data structure, vertices, edges, and paths are fundamental concepts that help in representing and understanding the relationships between objects. In this article, we will explore what vertices, edges, and paths are, and how they contribute to the overall structure of a graph.


A vertex, also known as a node, is a fundamental unit in a graph. It represents an object or an entity.

Vertices are typically depicted using circles or points. For example, in a social network graph, each person can be represented as a vertex.

Example: Consider the following graph:

   A ----- B
  / \
 /   \

In this graph, A, B, C, and D are vertices.


An edge represents a connection or relationship between two vertices. It is represented by a line or an arrow connecting two vertices. Edges can be directed (one-way) or undirected (two-way).

Example: In the above graph:

  • The edge connecting A and B is undirected.
  • The edge connecting A and C is undirected.
  • The edge connecting A and D is directed from A to D.


A path in a graph represents a sequence of edges that connect two or more vertices. It shows how one vertex can be reached from another vertex by traversing through intermediate vertices.

Example: In the above graph:

  • A path from A to B can be: A -> B
  • A path from C to D can be: C -> A -> D
  • A path from D to B can be: D -> A -> B

Paths can be of different lengths and can contain cycles (when a path leads back to a vertex it has already visited).

Understanding vertices, edges, and paths is crucial for working with graph data structures. They form the building blocks of more complex graph algorithms and operations.

Now that you have a good understanding of what vertices, edges, and paths are in graph data structure, you can apply this knowledge to solve problems involving graphs and analyze relationships between objects.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy