Graph TheoryTopic #22 of 40

Graph Basics

Vertices, edges, directed and undirected graphs, adjacency matrices, and graph terminology.

Definition

A graph G=(V,E)G = (V, E) consists of:

  • VV: a set of vertices (nodes)
  • EE: a set of edges (connections between vertices)

Types of Graphs

Undirected Graph

Edges have no direction: {u,v}\{u, v\} connects uu and vv symmetrically.

Directed Graph (Digraph)

Edges have direction: (u,v)(u, v) goes from uu to vv.

Simple Graph

  • No loops (edges from vertex to itself)
  • No multiple edges between same vertices

Multigraph

Multiple edges between vertices allowed.

Pseudograph

Loops and multiple edges allowed.

Weighted Graph

Each edge has an associated numerical value (weight).

Basic Terminology

Vertices

TermDefinition
AdjacentTwo vertices connected by an edge
NeighborA vertex adjacent to vv
Degree d(v)d(v)Number of edges incident to vv
Isolated vertexVertex with degree 0
Pendant vertexVertex with degree 1

Edges

TermDefinition
IncidentEdge ee is incident to vertices it connects
LoopEdge connecting vertex to itself
Multiple edgesTwo or more edges between same vertices

Degree

Undirected Graphs

d(v)=number of edges incident to vd(v) = \text{number of edges incident to } v

(Loops count twice)

Handshaking Lemma

vVd(v)=2E\sum_{v \in V} d(v) = 2|E|

Each edge contributes 2 to the total degree.

Corollary: The number of vertices with odd degree is even.

Directed Graphs

  • In-degree d(v)d^-(v): edges coming into vv
  • Out-degree d+(v)d^+(v): edges going out of vv

vVd(v)=vVd+(v)=E\sum_{v \in V} d^-(v) = \sum_{v \in V} d^+(v) = |E|

Graph Representations

Adjacency List

For each vertex, list its neighbors.

Example: Triangle (vertices 1, 2, 3)

1: [2, 3]
2: [1, 3]
3: [1, 2]

Space: O(V+E)O(|V| + |E|)

Adjacency Matrix

A[i][j]=1A[i][j] = 1 if edge between ii and jj, else 0.

Example: Triangle A=(011101110)A = \begin{pmatrix} 0 & 1 & 1 \\ 1 & 0 & 1 \\ 1 & 1 & 0 \end{pmatrix}

Space: O(V2)O(|V|^2)

Incidence Matrix

Rows = vertices, Columns = edges. M[v][e]=1M[v][e] = 1 if vv is incident to ee.

Special Graphs

Complete Graph KnK_n

Every pair of vertices is connected.

  • Vertices: nn
  • Edges: (n2)=n(n1)2\binom{n}{2} = \frac{n(n-1)}{2}
  • Each vertex has degree n1n - 1

Complete Bipartite Graph Km,nK_{m,n}

Vertices split into two groups of size mm and nn. Every vertex in one group connected to every vertex in the other.

  • Edges: m×nm \times n

Cycle CnC_n

nn vertices in a cycle. Each vertex has degree 2.

Path PnP_n

nn vertices in a line. Two endpoints have degree 1, others have degree 2.

Wheel WnW_n

Cycle CnC_n plus a central hub connected to all cycle vertices.

  • Vertices: n+1n + 1
  • Edges: 2n2n

n-Cube QnQ_n

Vertices are nn-bit binary strings. Edge between two vertices if they differ in exactly one bit.

  • Vertices: 2n2^n
  • Edges: n2n1n \cdot 2^{n-1}
  • Regular with degree nn

Subgraphs

H=(V,E)H = (V', E') is a subgraph of G=(V,E)G = (V, E) if:

  • VVV' \subseteq V
  • EEE' \subseteq E
  • All edges in EE' have endpoints in VV'

Induced Subgraph

Given VVV' \subseteq V, the induced subgraph G[V]G[V'] includes all edges of GG with both endpoints in VV'.

Spanning Subgraph

A subgraph that includes all vertices of GG.

Graph Operations

Union

G1G2=(V1V2,E1E2)G_1 \cup G_2 = (V_1 \cup V_2, E_1 \cup E_2)

Complement

G\overline{G} has the same vertices as GG, with edge (u,v)(u, v) iff (u,v)(u, v) is NOT in GG.

For simple graphs: E(G)+E(G)=(n2)|E(G)| + |E(\overline{G})| = \binom{n}{2}

Contraction

Remove an edge (u,v)(u, v) and merge uu and vv into a single vertex.