Graph Theory: Part I (Introduction)

This is the first in a multi-part series about graph theory here on 20bits. This started out of me wanting to write about some of the mathematical aspects of Facebook, but I realized that many people might not have a sufficient background to just jump right in. Rather than cover the all the ground in one article I decided to break it up into multiple parts. This is the first part, a quick introduction to graph theory.

Graph theory is a fundamental area of study in discrete mathematics. As the name implies graph theory is about graphs, so I'll first define graph and then discuss why people are so interested in studying these critters. I'm going to assume you're familiar with the idea of ordered pairs and sets.

Some Definitions

Definition. A graph G is a pair (V,E) of sets, called the vertex set and edge set. V is a collection of abstract vertices, written {v 1 , v 2 ,...,v n } and E is a collection of ordered pairs of vertices, called edges.

As you can see, this is pretty abstract. The definition leaves you free to define both what the vertices and edges are, precisely. Vertices could be cities and edges could be interstate highways. An example:

This type of graph is called a directed graph because some of the edges have a direction, i.e., they only go one way. Going back to the original definition, we have V = {v 1 ,v 2 ,v 3 ,v 4 } and E = {(v 1 ,v 2 ),(v 1 ,v 3 ),(v 1 ,v 4 ),(v 2 ,v 3 )}

Definition. Let G be a graph, then we write V(G) to mean the vertex set of G and E(G) to mean the edge set. We will just write V and E if the context makes it clear which graph we're talking about.

Definition. Let G be a graph and let u,v ∈ V(G). We write v ~ u if there is an edge connecting v to u, i.e., if (v,u) ∈ E(G).

Sometimes we don't care about direction and can make edges directionless. These sorts of graphs are called undirected graphs and look like this

Definition. A graph G is an undirected graph if u ~ v implies v ~ u for all u,v ∈ V(G).

Concrete examples

I'd be remiss if I kept talking like graph theory is some pie-in-the-sky theoretical abstraction. In fact, many real-world situations can be modeled using graph theory. Some examples:

Shipping routes The vertices are shipping hubs and the edges are the routes between them

Social networks The vertices are people and the edges are social connections (e.g., p ~ q is p is a friend of q)

Telecommunications networks The vertices are computers on the network and the edges are the network connections between them

Disease transmission The vertices are organisms which can carry the disease and the edges represent one organism spreading it to another

Sexual networks The vertices are people and the edges denote which pairs have slept together (see, e.g., The Structure of Romantic and Sexual Relations at Jefferson High)

More Definitions

Essentially any situation where you want to consider pairs of objects and the connections between those pairs can be analyzed using graph theory. There are a few more definitions to cover.

Definition. A graph loop or just loop is a vertex v which is connected to itself, i.e., v ~ v. A graph with no such loops is called a simple graph.

Note. Some authors allow multiple edges between vertices. In this situation graphs with no loops and at most one edge between any two vertices is called a simple graph. Although this type of graph is less than ideal for analysis it occurs relatively frequently in reality, e.g., two different roads connecting a pair of cities or redundant network connections. I'll make sure to note where we are dealing with such graphs and how we work around it.

Definition. Let G be a graph. A path or a walk is a collection of vertices v 1 , v 2 , ..., v k } such that v i ~ v i+1 for all i, 1 ≤ i < k. A path with no repeated vertices is called simple, and a path such that v k ~ v 1 is called a closed path, closed walk, or a cycle.

Definition. A weighted graph G is a graph such that each edge in E(G) has an associated weight, typically a real number.

Weighted graphs are the stuff of many famous algorithms. There are a whole slew of algorithms dedicated to finding the shortest path between two vertices in a weighted graph, where "shortest" means the path with the smallest weight. The algorithms vary in performance depending on several factors: the ratio of vertices to edges, whether the graph has negative weights, whether we have a good heuristic for determining what a path might cost, etc.

Important Graphs

There are some graphs every student of computer science or discrete mathematics is just sort of expected to know.