12Graph Theory
12.1 What Is Graph Theory?
Graph theory is a branch of discrete mathematics that studies the properties and applications of graphs. A graph is a mathematical structure that consists of a set of vertices (also known as nodes) and a set of edges that connect pairs of vertices. Graph theory has numerous applications in computer science, engineering, social sciences, and other fields.
12.1.1 Definition of a Graph
A graph G is defined as an ordered pair (V, E), where:
- V is a finite, non-empty set of vertices (or nodes).
- E is a set of edges, where each edge is an unordered pair of vertices (u, v), with u, v ∈ V.
In other words, a graph is a collection of vertices, some (possibly all) of which are connected by edges. The vertices represent objects or entities, while the edges represent relationships or connections between those objects or entities.
Here is an example of a graph:
The vertices in this graph are labeled as A through E, and the edges are represented by the line segments connecting the vertices. As an illustration of potential relationships illustrated here, suppose A = Alphonse, B = Betty, C = Cerano, D = Dao, E = Elise, and the edges represent friendship relationships. Here, you see Betty is friends with Dao, Alphonse, and Cerano, but not with Elise.
There are two main types of graphs:
- Undirected graphs: In an undirected graph, the edges are bidirectional, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access