Introduction to Graph Theory
Understand graph fundamentals, connectivity and tree properties, and special families such as bipartite and planar graphs with Euler’s formula.
Summary
Read Summary
Flashcards
Save Flashcards
Quiz
Take Quiz
Quick Practice
What is the fundamental unit of a graph, also known as a node?
1 of 20
Summary
Graph Theory: Definitions and Basic Properties
Introduction
Graphs are one of the most important data structures in computer science and mathematics. A graph provides a way to represent relationships or connections between objects. Whether you're modeling social networks, transportation systems, web pages, or molecules, graphs offer a unified framework. This guide covers the fundamental definitions and properties of graphs that form the foundation for all graph-based problems you'll encounter.
Definitions of Graphs
The Basic Components
A graph is a mathematical structure consisting of two key components:
Vertices (also called nodes) are the fundamental units of a graph. Think of them as points or objects. In practical applications, vertices might represent cities, people, computers, or any entities you want to model.
Edges are connections between vertices. An edge links a pair of vertices together, representing a relationship or connection between them.
Types of Graphs: Directed vs. Undirected
The distinction between undirected graphs and directed graphs is crucial and affects how we interpret the relationships in the graph.
In an undirected graph, edges have no direction. If there's an edge between vertex A and vertex B, the connection works both ways—you can think of it as a two-way relationship. These edges are represented as unordered pairs of vertices. Undirected graphs are useful for modeling relationships like friendships (if A is friends with B, then B is friends with A) or roads connecting cities (you can travel in both directions).
In a directed graph (or digraph), edges point from one vertex to another, representing one-way relationships. Each edge has a tail (the origin vertex) and a head (the destination vertex). An arrow shows the direction of the edge. Directed graphs are useful for modeling things like web links (a webpage links to another), Twitter follows (A follows B, but B might not follow A), or task dependencies (task A must be completed before task B).
Simple Graphs
A simple graph has two important restrictions:
It contains no loops: a loop is an edge that connects a vertex to itself. This doesn't make sense in many practical scenarios.
It contains no multiple edges: there is at most one edge between any pair of vertices. You either have a connection or you don't.
Unless stated otherwise, assume you're working with simple graphs.
Basic Notions
Vertex Degree
The degree of a vertex measures how many connections it has. The specific definition depends on whether your graph is directed or undirected.
In an undirected graph, the degree of a vertex is simply the count of edges connected to it. For example, if vertex A has edges to B, C, and D, then the degree of A is 3. Degree tells you how "popular" or "connected" a vertex is in the network.
In a directed graph, we distinguish between two types of degree:
In-degree counts the number of edges arriving at (pointing to) a vertex
Out-degree counts the number of edges leaving (pointing from) a vertex
For example, if vertex A has edges coming in from B and C, and edges going out to D and E, then A has in-degree 2 and out-degree 2.
A useful fact: in any directed graph, the sum of all in-degrees equals the sum of all out-degrees, which both equal the total number of edges.
Paths and Cycles
A path is a sequence of edges that connects vertices without repeating any edge. Think of a path as a route through the graph. A path from vertex A to vertex B shows you can "travel" from A to B following the edges of the graph. The length of a path is the number of edges it contains.
A cycle is a special kind of path: it's a closed path that starts and ends at the same vertex, without repeating any edges. Cycles are important because they represent the possibility of returning to where you started. For example, in a social network, a cycle might represent a chain of introductions that leads back to the original person.
A key distinction: a simple path doesn't repeat vertices (except possibly the start and end), while a simple cycle is a closed simple path.
Connectivity
A graph is connected if there is a path between every pair of vertices. In other words, you can travel from any vertex to any other vertex by following the edges. This is an important property—a disconnected graph breaks into separate pieces where some vertices cannot reach others.
For directed graphs, there's a related concept: a directed graph is strongly connected if there's a directed path from every vertex to every other vertex.
Trees: A Special Case
A tree is one of the most important graph structures. A tree is defined as a connected graph that contains no cycles. Trees are acyclic, meaning you can never return to the starting point by following edges without backtracking.
Trees have a special property: a tree with $n$ vertices has exactly $n - 1$ edges. This relationship is fundamental and often used to verify whether a connected graph is a tree. For example:
A tree with 4 vertices must have exactly 3 edges
A tree with 10 vertices must have exactly 9 edges
This makes sense intuitively: each edge beyond $n-1$ would create a cycle, breaking the tree property.
Special Families of Graphs
Bipartite Graphs
A bipartite graph has a special structure: its vertices can be divided into two disjoint sets (call them Set A and Set B) such that every edge connects a vertex in Set A to a vertex in Set B. No edges exist within Set A, and no edges exist within Set B—all connections go between the two sets.
Bipartite graphs model many real-world scenarios: students and courses (edges represent enrollment), employers and job candidates (edges represent applications), or actors and movies (edges represent appearances).
Key property: A graph is bipartite if and only if it contains no odd-length cycles. This means any cycle in a bipartite graph must have an even number of edges. This property gives you a way to check if a graph is bipartite: if you ever find a cycle of odd length, the graph is not bipartite.
Planar Graphs
A planar graph can be drawn on a flat sheet of paper without any edges crossing each other. This is a geometric property—it's about how you can visualize the graph, not about the abstract structure itself. Note that the same graph can be drawn in different ways; what matters is whether some way of drawing it exists without crossings.
Planar graphs are important in circuit design, map coloring, and many other applications.
Euler's Formula is a fundamental result for connected planar graphs:
$$V - E + F = 2$$
where:
$V$ = number of vertices
$E$ = number of edges
$F$ = number of faces (regions created by the drawing, including the outer infinite region)
This formula beautifully connects the combinatorial structure (vertices and edges) with the geometric property (faces).
Example: A simple planar graph—a triangle—has 3 vertices, 3 edges, and 2 faces (inside and outside). Check: $3 - 3 + 2 = 2$ ✓
Constraints on Planar Graphs
Not all graphs can be drawn without crossings. Planar graphs must satisfy certain inequality constraints.
For planar graphs with $V \geq 3$ vertices, the following inequality must hold:
$$E \leq 3V - 6$$
This is a necessary condition: if a graph violates this inequality, it cannot be planar. However, satisfying this inequality doesn't guarantee planarity—a graph could satisfy the bound and still be non-planar.
This inequality tells us that planar graphs cannot have too many edges relative to their vertices. The more vertices you have, the more edges you can add, but always within this bound.
Flashcards
What is the fundamental unit of a graph, also known as a node?
Vertex
What component of a graph serves as a connection joining a pair of vertices?
Edge
How are edges defined in an undirected graph regarding the direction of the connection?
Edges connect vertices without any direction
In an undirected graph, how are edges represented as pairs of vertices?
Unordered pairs
What does the degree of a vertex represent in an undirected graph?
The number of incident edges
What is the alternative name for a directed graph where edges point from one vertex to another?
Digraph
What are the two specific components (origin and destination) of an edge in a directed graph?
Tail and Head
What term describes the number of edges arriving at a vertex in a directed graph?
In-degree
What term describes the number of edges leaving a vertex in a directed graph?
Out-degree
What two specific characteristics define a simple graph?
Contains no loops (edges starting and ending at the same vertex)
Contains no multiple edges (at most one edge between any pair of vertices)
What is a sequence of edges that moves between vertices without repeating any edges?
Path
What is a closed path that returns to its original starting vertex?
Cycle
When is a graph considered "connected"?
When a path exists between every pair of its vertices
How is a tree defined in terms of connectivity and cycles?
A connected graph that contains no cycles
In a tree with $n$ vertices, exactly how many edges are present?
$n - 1$ edges
How are vertices and edges organized in a bipartite graph?
Vertices are divided into two disjoint sets where every edge joins a vertex from one set to the other
What type of cycles are notably absent in bipartite graphs?
Odd-length cycles
What is the defining spatial property of a planar graph?
It can be drawn on a flat surface without any edges crossing
What is Euler's formula for connected planar graphs?
$V - E + F = 2$ (where $V$ is vertices, $E$ is edges, and $F$ is faces)
What inequality must a planar graph satisfy if it has $V \ge 3$ vertices?
$E \le 3V - 6$ (where $E$ is edges and $V$ is vertices)
Quiz
Introduction to Graph Theory Quiz Question 1: How are edges characterized in an undirected graph?
- They have no direction (correct)
- They point from a tail to a head
- They are ordered triples of vertices
- They always form cycles
Introduction to Graph Theory Quiz Question 2: What is a loop that a simple graph does not allow?
- An edge that starts and ends at the same vertex (correct)
- An edge connecting two distinct vertices
- A set of three mutually adjacent vertices
- A path that visits every vertex exactly once
Introduction to Graph Theory Quiz Question 3: How are edges represented in an undirected graph?
- As unordered pairs of vertices (correct)
- As ordered pairs with a tail and head
- As triples including a weight
- As directed arcs only
Introduction to Graph Theory Quiz Question 4: What does the degree of a vertex count in an undirected graph?
- The number of incident edges (correct)
- The number of outgoing edges
- The number of incoming edges
- The number of faces adjacent to the vertex
Introduction to Graph Theory Quiz Question 5: What does the out‑degree of a vertex measure in a directed graph?
- The number of edges leaving the vertex (correct)
- The number of edges arriving at the vertex
- The total number of incident edges
- The number of cycles containing the vertex
Introduction to Graph Theory Quiz Question 6: When is a graph considered connected?
- When a path exists between every pair of its vertices (correct)
- When it contains at least one cycle
- When it can be drawn without edge crossings
- When it has equal numbers of vertices and edges
Introduction to Graph Theory Quiz Question 7: How many edges does a tree with $n$ vertices have?
- $n - 1$ edges (correct)
- $n$ edges
- $2n - 3$ edges
- $\frac{n(n-1)}{2}$ edges
Introduction to Graph Theory Quiz Question 8: In a simple graph, an edge always joins how many vertices?
- Two (correct)
- One
- Three
- Four
Introduction to Graph Theory Quiz Question 9: In Euler’s formula $V - E + F = 2$ for a connected planar graph, what does the symbol $F$ represent?
- Number of faces (correct)
- Number of edges
- Number of vertices
- Number of components
Introduction to Graph Theory Quiz Question 10: A planar graph with 10 vertices can have at most how many edges?
- 24 (correct)
- 20
- 30
- 15
Introduction to Graph Theory Quiz Question 11: Which condition must a graph satisfy to be called planar?
- It can be drawn on a plane so that no two edges intersect (correct)
- It contains no cycles of length three
- Every vertex is adjacent to every other vertex
- Its vertices can be colored with only two colors
Introduction to Graph Theory Quiz Question 12: In the definition of a path, what does the condition “without repeating edges” imply?
- No edge appears more than once in the sequence (correct)
- No vertex appears more than once in the sequence
- The path must start and end at the same vertex
- All edges must be directed
Introduction to Graph Theory Quiz Question 13: In the definition of a bipartite graph, what does it mean that the two vertex sets are “disjoint”?
- The sets share no vertices in common (correct)
- Each set contains the same number of vertices
- Every vertex belongs to both sets simultaneously
- The sets are connected by a single edge
How are edges characterized in an undirected graph?
1 of 13
Key Concepts
Graph Fundamentals
Graph
Vertex
Edge
Vertex degree
Graph Types
Directed graph
Undirected graph
Simple graph
Connected graph
Tree
Planar graph
Graph Properties
Path
Cycle
Definitions
Graph
A set of vertices (nodes) together with a collection of edges (links) that connect pairs of vertices.
Vertex
A fundamental unit or node in a graph representing an entity or point.
Edge
A connection between two vertices in a graph, representing a relationship or link.
Directed graph
A graph whose edges have an orientation, indicating a direction from a tail (origin) to a head (destination).
Undirected graph
A graph whose edges are unordered pairs of vertices, implying no inherent direction.
Simple graph
A graph that contains no loops (edges from a vertex to itself) and no multiple edges between the same pair of vertices.
Vertex degree
The number of edges incident to a vertex in an undirected graph; in directed graphs, distinguished as in‑degree and out‑degree.
Path
A sequence of edges that connects a series of distinct vertices without repeating edges.
Cycle
A closed path that starts and ends at the same vertex, with no other repetitions of vertices or edges.
Connected graph
A graph in which there exists a path between every pair of vertices.
Tree
A connected acyclic graph; a tree with n vertices has exactly n − 1 edges.
Planar graph
A graph that can be drawn on a plane without any edges crossing each other.