Introduction to Graphs
Definition of Graphs
Definition of Graph
graph G = ( V , E )
V: non empty set of vertices (nodes)
E: set of edges connecting its endpoints, with each edge has 1 or 2 vertices associated with it (called endpoints)
Finite vs Infinite graph:
finite: both |V| and |E| are finite
infinite: otherwise
Simple graph:
Each edge connects two different (unordered) vertices: here
No 2 edges connect same pair of vertices: here
no edge connects a vertex to itself (loop): here
Multigraph
graphs of multiple edges connecting the same vertices
Pseudographs
include loops, possibly multiple edges
Undirected graph
all edges are undirected
ie. unordered pairs (or set) {u, v}
Directed graphs (digraph)
Traits
(V,E)
non empty set of vertices V
set of directed edges (arcs)
each directed edge associate with ordered pair of vertices, i.e. (u,v), and start at u and end at v
Different graphs types
Simple directed graph
no loop, no multiple directed edges
directed multigraphs
have multiple directed edges from a vertex to a second (possibly the same) vertex
multiplicity m
m directed edge from (u,v)
mixed graph
both undirected and directed edges
hypergraph
summary: here
Terminology
Adjacent/ neighbor: a and b vertices are called adjacent if it is connected by an edge e
Neighborhood:
N ( x ) = { a , b , c , d } in which vertex v is adjacent to a,b,c,d
N ( x , y ) = N ( x ) ⊠N ( y ) = { f }
degree of a vertex:
undigraph:
number of edges adjacent to it, loop = +2 to the deg
d e g ( v )
Handshaking theorem :
2 m = â v â V â d e g ( v ) : total number of degrees is two times the edges
undigraph has EVEN number of vertices of ODD degree
prove by showing 2 m = â v â V 1 â â d e g ( v ) + â v â V 2 â â d e g ( v ) , each of the 3 terms are even (V 1 â : set of vertices of even degree, V 2 â : set of vertices of odd degree)
but all terms in â v â V 2 â â d e g ( v ) are odd â even number of such terms â âĢ V 2 â âĢ is even
digraph:
pendant: vertex of deg = 1
isolate: vertex of deg = 0
Graph representations
impact: affect storage size, efficiency of various graph algorithms
Adjacency matrix
space complexity: n 2
illustration: here
Adjacency list
Edge list
illustration: here
set of vertices that have at least one edge entering or leaving, denoted in the right order
Directed graph
definition & terms
a â b, with (a,b) is an edge in graph G
vertex a is adjacent TO b
b â c, with (b,c) is an edge in graph G
vertex c is adjacent FROM b
degrees ^0f3d92
in-degree: d e g â ( a ) : a is the terminal (end) vertex
out-degree: d e g + ( b ) : b is the initial (start) vertex
ÎĢ v â V â d e g â ( v ) = ÎĢ v â V â d e g + ( v ) = âĢ E âĢ : sum all in and out degrees is equal to total no. of edges
prove: each connection will contribute 1 to in-deg and 1 to out-deg
Special simple graphs
complete graph on n vertices or K n â : simple graph, exactly 1 edge btw each pair of distinct vertices
2 n ( n â 1 ) â edges in a complete graph with n âĨ 2 vertices
noncomplete graph: simple graph, at least 1 pair of distinct vertices not connected by an edge