09 Introduction to Graph Theory

A structured introduction to graph theory covering graph terminology, representations, degrees, routes, cycles, connectivity, and subgraphs.

structure and terminology

theory studies relationships among objects. A is written as

G=(V,E),G=(V,E),

where VV is a set of vertices and EE is a set of edges. For example, consider

V={a,b,c,d},E={ab,ac,bc,cd}.V=\{a,b,c,d\},\qquad E=\{ab,ac,bc,cd\}.

This has four vertices and four edges. Vertices aa and bb are adjacent because the edge abab joins them. The edge abab is incident with both endpoints, aa and bb.

The neighborhood of a vv, written N(v)N(v), is the set of vertices adjacent to vv. In this example,

N(a)={b,c}.N(a)=\{b,c\}.

Unless stated otherwise, introductory theory commonly uses simple undirected graphs:

  • An undirected edge has no direction, so uvuv and vuvu represent the same edge.

  • A simple has no loops and no repeated edges.

  • A loop joins a to itself.

  • A multigraph may have multiple edges joining the same pair of vertices.

  • A directed uses directed edges such as (u,v)(u,v).

  • A weighted assigns a numerical value to each edge.

The order of a is ∣V∣|V|, and its size is ∣E∣|E|. An empty has no edges, while a trivial has one and no edges.

The term refers to the complete structure of vertices and edges, while the term refers to one of the individual objects in that structure.

Takeaway: A describes objects through vertices and relationships through edges; adjacency and incidence specify how those parts are connected.

Ways to represent a

Different representations emphasize different features of the same . For the with

V={a,b,c,d},E={ab,ac,bc,cd},V=\{a,b,c,d\},\qquad E=\{ab,ac,bc,cd\},

the main representations are as follows.

  • An edge list records the edges directly:

    (ab,ac,bc,cd).(ab,ac,bc,cd).
  • An adjacency list records the neighbors of each . For example, the entries are a ⁣: ⁣b,ca\!:\!b,c, b ⁣: ⁣a,cb\!:\!a,c, c ⁣: ⁣a,b,dc\!:\!a,b,d, and d ⁣: ⁣cd\!:\!c.

  • An adjacency matrix is a square matrix whose rows and columns correspond to vertices. For a simple undirected , an entry is 11 when the corresponding vertices are adjacent and 00 otherwise. In the order (a,b,c,d)(a,b,c,d),

    A=(0110101011010010).A=\begin{pmatrix} 0&1&1&0\\ 1&0&1&0\\ 1&1&0&1\\ 0&0&1&0 \end{pmatrix}.

    An undirected has a symmetric adjacency matrix, and a simple has zeros on the diagonal.

  • An incidence matrix has rows for vertices and columns for edges. Its entry is 11 when the is an endpoint of the edge and 00 otherwise. In a simple undirected , each column contains two entries equal to 11.

A drawing is also a representation. Its exact geometric appearance is unimportant: moving vertices or bending edges does not change the as long as the same incidences are preserved.

For sparse graphs, meaning graphs with relatively few edges compared with the maximum possible number, adjacency lists are often more economical than adjacency matrices. Adjacency matrices, however, make adjacency tests direct and are useful in algebraic and computational settings.

Takeaway: Choose a representation according to the task: lists are convenient for enumerating connections, matrices support systematic tests, and drawings provide an immediate visual picture.

Degrees and the

The of a measures its local connectivity. In the example ,

deg⁡(a)=2,deg⁡(b)=2,deg⁡(c)=3,deg⁡(d)=1.\deg(a)=2,\qquad \deg(b)=2,\qquad \deg(c)=3,\qquad \deg(d)=1.

The sequence, usually listed in nonincreasing order, is therefore

(3,2,2,1).(3,2,2,1).

A is regular when every has the same . If every has rr, the is called rr-regular.

The provides a useful consistency check:

∑v∈Vdeg⁡(v)=2∣E∣.\sum_{v\in V}\deg(v)=2|E|.

For this ,

2+2+3+1=8=2(4).2+2+3+1=8=2(4).

The factor of 22 appears because every edge contributes one incidence at each of its two endpoints. Consequently, every finite undirected has an even number of odd- vertices.

A with 00 is isolated, so it has no neighbors. A with 11 is a leaf or pendant . If loops are allowed, a loop contributes 22 to the because it creates two endpoint incidences at the same .

Takeaway: Degrees summarize local structure, while the connects all local counts to the 's total number of edges.

Walks, trails, paths, and cycles

Routes through a are classified by what they are allowed to repeat. A walk is a sequence of vertices

v0,v1,…,vkv_0,v_1,\ldots,v_k

such that consecutive vertices are adjacent. Its length is kk. Both vertices and edges may repeat. For example, a,b,c,a,ca,b,c,a,c is a walk of length 44 in the example .

A trail is a walk that does not repeat an edge, although it may repeat vertices. The sequence a,b,c,da,b,c,d is a trail.

A is a walk that does not repeat vertices. For example, a,c,da,c,d is a of length 22 from aa to dd. The sequence a,b,c,aa,b,c,a is not a because it repeats aa.

A shortest between two connected vertices has the smallest possible length. That length is the distance between the vertices, commonly written d(u,v)d(u,v). The PnP_n has nn vertices and n−1n-1 edges.

A is a closed : it starts and ends at the same , with no other repeated. In the example,

a,b,c,aa,b,c,a

is a of length 33. The CnC_n has nn vertices and nn edges, and every in it has 22.

The distinctions can be organized as follows:

  • A walk may repeat vertices and edges.

  • A trail may repeat vertices but not edges.

  • A repeats neither vertices nor edges.

  • A is a closed .

Takeaway: The restrictions become progressively stronger from walk to trail to ; cycles add the condition of returning to the starting .

Connectivity and components

Connectivity describes whether vertices can reach one another. Two vertices are connected when there is a between them. A is connected when every pair of vertices is connected.

The with edges ab,ac,bc,cdab,ac,bc,cd is connected because, for example, a,c,da,c,d is a from aa to dd. A that is not connected is disconnected, and its connected components are its maximal connected pieces.

For example, suppose

V={a,b,c,d,e},E={ab,bc,de}.V=\{a,b,c,d,e\}, \qquad E=\{ab,bc,de\}.

The connected components have sets

{a,b,c}and{d,e}.\{a,b,c\}\quad\text{and}\quad\{d,e\}.

An isolated forms a component by itself. A is connected precisely when it has one .

Connectivity does not require a unique route. There may be multiple paths between two vertices. In fact, two distinct paths between the same pair of vertices imply that the contains a : following one forward and the other backward produces a closed route with a repeated starting point.

A with no cycles is acyclic. A connected acyclic is called a tree.

Takeaway: Paths determine reachability, connected components partition a disconnected into maximal reachable regions, and cycles provide alternative routes.

Subgraphs and selected structure

A subgraph is a smaller contained within a larger . If G=(V,E)G=(V,E), then H=(W,F)H=(W,F) is a subgraph of GG when

W⊆V,F⊆E,W\subseteq V,\qquad F\subseteq E,

and every edge in FF has both endpoints in WW. A subgraph can be created by deleting vertices, deleting edges, or doing both.

For

V={a,b,c,d},E={ab,ac,bc,cd},V=\{a,b,c,d\}, \qquad E=\{ab,ac,bc,cd\},

choosing

W={a,b,c},F={ab,bc}W=\{a,b,c\}, \qquad F=\{ab,bc\}

defines a valid subgraph. The edge cdcd cannot be included because d∉Wd\notin W.

Two important special cases are:

  • A spanning subgraph contains every of the original but may contain only some of its edges. Thus, it has the form H=(V,F)H=(V,F) with F⊆EF\subseteq E.

  • An is determined by a chosen set WW. It contains every original edge whose endpoints are both in WW, and is written G[W]G[W].

For the example, the on {a,b,c}\{a,b,c\} contains all three edges abab, acac, and bcbc. A on the same three vertices that omits acac is still a subgraph, but it is not the on that set.

A can be viewed as an consisting of one maximal set of mutually reachable vertices.

Takeaway: A general subgraph may omit selected vertices or edges, a spanning subgraph keeps all vertices, and an keeps every edge allowed by its selected vertices.

An integrated example

Consider the

V={1,2,3,4,5},E={12,23,31,34,45}.V=\{1,2,3,4,5\}, \qquad E=\{12,23,31,34,45\}.

Its order is 55, and its size is 55. The degrees are

deg⁡(1)=2,deg⁡(2)=2,deg⁡(3)=3,deg⁡(4)=2,deg⁡(5)=1.\deg(1)=2,\quad \deg(2)=2,\quad \deg(3)=3,\quad \deg(4)=2,\quad \deg(5)=1.

The sum verifies the :

2+2+3+2+1=10=2∣E∣.2+2+3+2+1=10=2|E|.

The sequence 1,2,3,11,2,3,1 is a of length 33, while 1,3,4,51,3,4,5 is a from 11 to 55. The is connected because every can be reached from every other .

The vertices 1,2,31,2,3, together with edges 12,23,3112,23,31, form a subgraph that is a . The vertices 3,4,53,4,5, together with edges 34,4534,45, form an induced subgraph on those vertices.

This example shows how the concepts fit together:

  • Degrees describe local connectivity.

  • Paths describe routes between vertices.

  • Cycles describe closed routes and alternative connections.

  • Connectivity describes the as a whole.

  • Subgraphs identify smaller structures inside the .

Final takeaway: To analyze a , first identify its vertices and edges, then examine representations and degrees, classify routes and cycles, determine connected components, and finally isolate relevant subgraphs.