Skip to main content

What is an edge in a graph?

An edge is a connection between two vertices in a graph. It shows that a relationship, path, or interaction exists between those vertices.

Example

  • In a social network, an edge is a follow or friendship between users.
  • On a road map, it is a road between cities.
  • In a computer network, it is a communication channel between devices.

Types of edges

  • In an undirected graph - the connection is two-way: if there is an edge between A and B, then A ↔ B.
  • In a directed graph - the connection has direction: A → B (it has a direction, like an arrow).

Weighted edges

Edges can have a weight - a numeric value showing distance, cost, or the strength of the connection.


Summary: an edge is a "bridge" between two vertices, which can be directed or two-way, weighted or not, and it is through edges that vertices in a graph interact.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.