← All Lessons Lesson 3 / 77
Lesson 3

Graph Terminologies: Vertex, Edge, Degree, and Path

Graph Terminologies

A graph is an advanced kind of data structure. Unlike an array or a linked list, where items sit one after another in a straight line, a graph can spread out in many directions. Because of this freedom, graphs can be drawn in countless shapes and forms.

This creates a problem. If every graph looks different, how do we talk about them clearly? We cannot keep drawing pictures every time we want to describe one. So we use a set of agreed-upon words — terminologies — that let us describe any graph precisely, using only words and numbers. Let's learn the most important ones.

Vertex

A vertex is simply a node in a graph. (Vertex is just the formal name for a node; the two words mean the same thing.) The plural of vertex is vertices.

Each vertex usually holds two things:

  • The data it stores (for example, a number like 500 or a name).
  • References to the nodes next to it, so the graph knows which vertices are connected.

Think of a vertex as a city on a map. The city has a name (its data), and it knows which other cities it has roads to.

Edge

An edge is the link that connects two vertices. If a vertex is a city, an edge is the road between two cities.

Edges come in two kinds:

  1. Undirected edge — a two-way connection. You can travel across it in both directions. This is like a normal two-way street: you can go from A to B and also from B to A. It is usually drawn as a plain line.
  2. Directed edge — a one-way connection. You can travel across it in only one direction. This is like a one-way street, and it is drawn as an arrow pointing the way you are allowed to go.

A single graph is allowed to mix both kinds. Some links can be two-way and others can be one-way in the very same graph.

Degree

The degree of a vertex is the number of edges touching that vertex. We say an edge is incident to a vertex when it is attached to it.

So if three edges connect to a vertex, that vertex has a degree of 3. It is just a simple count: how many lines come out of this node?

Indegree and Outdegree

When a graph uses directed (one-way) edges, a plain degree count is not enough. Direction matters, so we split the count into two parts:

  • Indegree — the number of edges pointing *into* the vertex (incoming arrows).
  • Outdegree — the number of edges pointing *out of* the vertex (outgoing arrows).

For example, if a vertex has two arrows coming in and one arrow going out, then its indegree = 2 and its outdegree = 1. Think of a city with two roads leading into it and one road leading away from it.

Path

A path is a way to get from one vertex to another by following a sequence of edges, one after the other. It is the route you take to travel from a source node to a destination node.

The key rule is that everything along the way must be distinct — you do not visit the same vertex twice and you do not reuse the same edge. A clean route from A to B, without circling back, is a path.

For example, to go from node A to node B, you might step through a few connected vertices in between. That chain of edges and vertices, with no repeats, is the path between A and B.

Why these words matter

Together, these terms let us describe any graph — no matter how tangled it looks — using clear language instead of drawings. Later in the course, they become the building blocks for defining whole *categories* of graphs and for explaining how graph algorithms work.

Graph Terminologies: Vertex, Edge, Degree, and Path
Diagram — click to zoom (scroll / drag to pan)