Lecture 11.2
Lecture 11.2
Lecture 11.2
1. Graphs
2. Graph Introduction
3. Graph Applications
4. Graph Representation
Graphs
Graph – mathematical object consisting of a set of:
V = nodes (vertices, points).
E = edges (links, arcs) between pairs of nodes.
Denoted by G = (V, E).
Captures pair wise relationship between objects.
Graph size parameters: n = |V|, m = |E|.
V = { 1, 2, 3, 4, 5, 6, 7, 8 }
E = { {1,2}, {1,3}, {2,3}, {2,4}, {2,5}, {3,5}, {3,7}, {3,8},
{4,5}, {5,6} }
n=8
m = 11
Graphs
Undirected Graph: A graph whose edges are unordered pairs of vertices. That is,
each edge connects two vertices where edge (u, v) = edge (v, u).
Directed Graph: A graph whose edges are ordered pairs of vertices. That is, each
edge can be followed from one vertex to another vertex where edge (u, v) goes
from vertex u to vertex v.
Acyclic Graph: A graph with no path that starts and ends at the same vertex.
1 2 1 2 1 2
3 4 3 4 3 4
A B
F C
E D d(A)=3, d(B)=3,d(C)=2
Weighted graph: associates weights with either the edges or the vertices
Connected: if every vertex of a graph can reach every other vertex, i.e., every
pair of vertices is connected by a path
Strongly connected: every 2 vertices are reachable from each other (in a
digraph)
Weighted Graph
Graph Applications
2
3
8
1 10
4
5
9
11
6
7
2
4 3
8 8
1 6 10
2 4 5
4 4 3
5
9
11
5 6
6 7
7
2
3
8
1 10
4
5
9
11
6
7
(a) (b)
(a) (b)
(a) (b)
(a) (b)
a. A directed graph G having five vertices and six edges.
b. The adjacency-list representation of G.
Graph Representation
(a) (b)
(a) (b)
1. https://en.wikipedia.org/wiki/Data_structure