Lesc3 GraphTheory
Lesc3 GraphTheory
Isit possible
to have a
walk in the
city of
Königsberg,
that crosses
each of the
seven bridges
only once?
In order to approach the problem, Euler
represented the important information as a
graph:
Some applications of Graph Theory
Models for communications and electrical
networks
Models for computer architectures
Network optimization models for operations
analysis, including scheduling and job
assignment
Analysis of Finite State Machines
Parsing and code optimization in compilers
Car navigation system
Efficient database
Build a bot to retrieve info off
WWW
PERT Chart in SysDes/SoftEng
What are graphs good for? Graphs are perhaps the most
pervasive abstraction in computer science. It is hard to
appreciate their tremendous usefulness at first, because
the concept itself is so elementary.
11
A graph is a bunch of vertices (or nodes)
represented by circles which are connected by
edges, represented by line segments
The graph is denoted as :
G = (V,E)
Properties of Vertex and Edge
An edge can either be a
Boolean property (connection vs. no
connection), or
encoded as a strength (distance, traveling
time, etc.)
A vertex can also contain information.
Kinds of Graph
Undirected Graph (Graph)
Consists of a set V of vertices and set E of edges such that an
edge e E is represented as an unordered pair of vertices where
e=(v,w) or e=(w,v)
* Modeling one way streets, hyperlinks in WWW
Directed Graph (Diagraph)
Consists of a set V of vertices and set E of edges such that an
edge e E is represented as an ordered pair of vertices where
e=(v,w)
Undirected Graph
V = { 1, 2, 3, 4} |V|=4
E = {(1,2), (2,3), (2,4), (4,1)} | E |=4
Degree of a Vertex
Degree of a vertex in an undirected graph is
the number of edges incident on it.
In a directed graph, the out degree of a
vertex is the number of edges leaving it and
the in degree is the number of edges
entering it.
2
2
1 3
3
1
4
4
The degree of
vertex 2 is 3
The in degree of
vertex 2 is 2 and the in
degree of vertex 4 is 1
2
2
1 3
3
1
4
4
The degree of
vertex 2 is 3
The in degree of
vertex 2 is 2 and the in
degree of vertex 4 is 1
Directed Graph
An edge e E of a directed graph is represented as an
ordered pair (v,w), where v, w V.
2
3
1
V = { 1, 2, 3, 4}, |V|=4
E = {(1,2), (2,3), (2,4), (4,1), (4,2)}, | E |=5
Cliques. A graph on n vertices where every pair of
vertices is connected is called a clique (or n-clique) and is
denoted by Kn.
V4 1 V5