Graph Theory-Basic
Graph Theory-Basic
1
Topics
Basics
Connectivity
Paths
2
1. Basics
3
1.1. Graphs and related objects
4
Undirected graph (simple graph)
5
Undirected graph (simple graph)
Example G(V,E)
V={a,b,c,d,e,f}
E={(a,b),(a,d),(b,e),(b,c),
(b,f),(c,f),(e,f)}
It is possible to write ab
instead of (a,b);
ab=ba.
6
Directed graph (digraph)
7
Mixed graph
Example
8
Multigraph
Edges with the same ends (or with the same head and tail) are
multiple edges.
If multiple edges are allowed, then a graph is called multigraph.
Example
9
Pseudograph
10
Combinations
11
Graph invariants
12
1.2. Adjacency and incidence
13
Adjacency and incidence
14
Neighbours
d e f
N(a)={b,d}
15
Neighbours
d e f
N+(a)={b}, N–(a)={d}
16
The degree of a vertex
a b c a b c
d e f d e f
17
The degree of a vertex
a b c
d e f
18
The degree of a vertex
19
The degree of a vertex
Examples
a b c a b c
d e f d e f
20
The degree of a vertex
Examples
a b c a b c
d e f d e f
21
Graph invariants
22
Particular cases
23
Handshaking lemma (Leonhard Euler)
d v 2q.
v 1
Lemma 2. Every finite undirected graph has an even number of
vertices with odd degree.
24
1.3. Isomorphism
25
Example: isomorphic graphs
a b c a f
e b
d e f d c
f
a b
d e
c
26
Example: nonisomorphic graphs
All the vertices 1, 3 and 5 (and 2, 4 and 6 ) of the graph on the left
are pairwise adjacent. There are no such three vertices in the
graph on the right.
1 2 a f
3 4 e b
5 6 d c
27
1.4. Types of graphs
K4 K5
28
Types of graphs
29
Types of graphs
30
Types of graphs
A complete bigraph
where |V1|=n, |V2|=m
is denoted as Knm.
K3,3
31
Types of graphs
32
1.5. Subgraphs
a b c a b
d e f d e f
G(V,E) G’(V’,E’)
33
Subgraphs
d e f e f
G(V,E) G’=G[{a,b,e,f}]
34
Subgraphs
a b c a b c
d e f d e f
G(V,E) G’(V,E’)
35
Subgraphs
a b c a b c
d e f e f
G(V,E) G’(V’,E’)
36
2. Connectivity
Walks
Distances
Connectivity of simple graphs
Connectivity of directed graphs
37
2.1. Walks
γ δ ε ζ η θ κ
d e f d e f
λ
<a,f> = a α b ζ f η c θ f κ c β b ζ f <a,f> = a b f c f c b f
38
Trail and tour
Trail <a,f> = a b f c b e f
Tour <a,a> = a b f c b e a
d e f
39
Path and cycle
A path (or a chain) is an open walk in which all the vertices (and
hence the edges) are different.
A cycle (or a circuit) is a closed walk in which all the vertices
are distinct.
Examples.
a b c
Path <a,f> = a b e f
Cycle <a,a> = a b f e a
d e f
40
2.2. Distances
42
Distances
a b c ε(a)=ε(b)=2
ε(c)=ε(d)=ε(e)=ε(f)=3
R(G)=2
D(G)=3
Peripheral vertices c, d, e, f
Centre a, b
d e f
43
2.3. Connectivity of simple graphs
d e f d e f
d e f e f e f
45
Articulation point and bridge
Examples.
de – bridge
d, e, h – articulation
points
46
Cuts
{ b, e } – vertex cut
d e f
47
Graph invariants
κ = 2 (vertices d, e)
d e f
48
Cuts for a pair of vertices
a b c
d e f
49
Menger theorem
50
2.4. Connectivity of directed graphs
51
Connectivity of directed graphs
52
Strongly connected component
53
Quotient graph
Graph traversal
Shortest path
55
3.1. Graph traversal
56
Graph traversal examples
BFS DFS
57
3.2. Shortest path
58
Shortest path
59
Shortest paths problems
The single-pair shortest path problem, in which we have to
find shortest paths from a source vertex v to a single
destination vertex u.
The single-source shortest path problem, in which we have
to find shortest paths from a source vertex v to all other vertices
in the graph.
The single-destination shortest path problem, in which we
have to find shortest paths from all vertices in the directed
graph to a single destination vertex v.
The all-pairs shortest path problem, in which we have to find
shortest paths between every pair of vertices v, u in the graph.
60
Shortest paths algorithms
61
4. Location problems
62
4.1. Distances in a weighted graph
Vertex-vertex distance
Point-vertex distance
Vertex-point distance
Vertex-edge distance
63
Vertex-vertex distance
64
F-point
66
Point-vertex distance
67
Point-vertex distance
Since
so f*[0,1].
68
Point-vertex distance
Example:
69
Point-vertex distance
Example:
70
Point-vertex distance
71
Point-vertex distance
Example:
72
Point-vertex distance
Example:
73
Vertex-point distance
74
Vertex-point distance
75
Vertex-point distance
76
Vertex-edge distance
For a directed edge (i,j) the maximum point f*=1 and the
vertex-edge distance
77
Vertex-edge distance
Example
(directed
edges):
78
Vertex-edge distance
79
Vertex-edge distance
Example
(undirected
edges):
80
Point-edge distance
81
Point-edge distance
82
Point-edge distance
83
Point-edge distance
For a directed edge (i,j)≠(k,l) the minimal path can pass only
through the vertex j:
84
Point-edge distance
85
Point-edge distance
86
Point-edge distance
Hence
87
Point-edge distance
88
Point-edge distance
89
Point-edge distance
90
Point-edge distance
Hence
91
Point-edge distance
92
Point-edge distance
93
Point-edge distance
94
Point-edge distance
Example
(undirected
edges):
95
Point-edge distance
96
Point-edge distance
i g f j
97
Point-edge distance
Example
(directed
edges):
98
Maximum distances
Maximum vertex-vertex:
Maximum point-vertex:
Maximum vertex-edge:
Maximum point-edge:
99
Total distances
Total vertex-vertex:
Total point-vertex:
Total vertex-edge:
Total point-edge:
10
4.2. Centers of a graph
Center
General center
Absolute center
General absolute center
10
Center
10
General center
10
Absolute center
10
Absolute center
Example.
10
Absolute center
10
Absolute center
10
Absolute center
10
Absolute center
10
Absolute center
Example.
For edge δ=(a,c):
11
General absolute center
11
General absolute center
Example.
11
General absolute center
11
4.3. Medians of a graph
Median
General median
Absolute median
General absolute median
11
Median
11
General median
11
Absolute median
11
General absolute median
11
General absolute median
11
General absolute median
Example.
12
General absolute median
Example.
12
General absolute median
Example
12
4.4. Extensions
Weighted location
Multicentres and multimedians
12
Weighted location
Suppose that different weights W(j) (W(i,j)) are associated with vertex j
(edge (i,j)). This weights can be considered as probabilities or
frequencies of visiting the vertex or the edge.
Vertex-vertex distance:
Vertex-edge distance:
12
Multicentres and multimedians
12
Multicentres and multimedians
Example. X3={c,(2/7)δ,(1/2)α}
12
Multicentres and multimedians
Example.
12
Multicentres and multimedians
Example.
12
Multicentres and multimedians
12
4.5. Absolute multicentres
Problems:
(a) Find the optimal location anywhere on the graph of a given
number (say p) of centres so that the distance required to reach the
most remote vertex from its nearest centre is a minimum.
(b) For a given "critical" distance, find the smallest number (and
location) of centres so that all the vertices of the graph lie within this
critical distance from at least one of the centres.
13
4.6. Multimedians
Problems:
(a) Find the optimal location anywhere on the graph of a given
number (say p) of medians so that the total distance required to reach
all the vertices from its nearest median is a minimum.
(b) For a given "critical" distance, find the smallest number (and
location) of medians so that the total distance required to reach all the
vertices from its nearest median lie within this critical distance.
13
Problem statement
Xp – multimedian (p-median)
v Xp – median vertex
v Xp – non-median vertex
13
Agenda
1. Adjacency Matrix of a Graph
2. Incidence Matrix of a Graph
3. Adjacency Lists
4. Trees and Properties of Trees
5. Characterization of Trees
6. Centers of Trees
7. Rooted Trees
8. Binary Trees
9. Spanning Trees and Forests
10. Spanning Trees of Complete Graphs
11. Application to Electrical Networks
12. Minimum Cost Spanning Trees
Adjacency Matrix of a Graph
Properties:
– Symmetric for undirected graphs.
– Useful for graph algorithms (e.g., finding paths, connectivity).
Incidence Matrix of a Graph
Definition: A matrix representing the relationship between vertices and
edges.
Properties:
– For undirected graphs: each column has exactly two 1s (the two vertices the edge
connects).
Adjacency Lists
Properties:
- Efficient in terms of space, especially for sparse
graphs.
- Provides quick access to adjacent nodes.
Trees and Properties of Trees
Properties:
– There is exactly one path between any two vertices.
– Removing any edge will disconnect the tree.
– A tree with n vertices has n-1 edges.
Characterization of Trees
Properties:
– A graph is a tree if it is connected and has no cycles.
– Every connected graph with n vertices and n-1 edges is a
tree.
– Recursive structures can define trees.
Centers of Trees
Properties:
– Trees have one or two centers.
– The center is used to analyze the structure and properties
of the tree, such as in network design.
Rooted Trees
Properties:
– Every edge points from a parent node to a child node.
– Commonly used in hierarchical structures and algorithms.
Binary Trees
Types:
– Full Binary Tree: Every node has 0 or 2 children.
– Complete Binary Tree: All levels are filled except possibly the
last, which is filled from left to right.
Applications:
– Data structures (e.g., binary search trees, heaps).
Spanning Trees and Forests
Definition:
- A spanning tree is a subgraph that includes all
vertices of the graph and is a tree.
- A forest is a collection of trees.
Properties:
– Every connected graph has at least one spanning tree.
– Spanning trees are fundamental in network design.
Spanning Trees of Complete
Graphs
Key Points:
– The number of spanning trees of a complete graph with n
vertices is n^(n-2) (Cayley's formula).
– Applications in optimal communication network design.
Application to Electrical Networks
Overview:
– Spanning trees model electrical circuits, where the tree
represents possible paths for current.
– Kirchhoff's theorem helps calculate the number of spanning
trees and analyze network stability.
Minimum Cost Spanning Trees
Definition: A spanning tree that minimizes the total edge cost in a
weighted graph.
Algorithms:
– Kruskal’s Algorithm: Greedy algorithm that adds edges with the
lowest weight until the spanning tree is complete.
– Prim’s Algorithm: Grows the tree by adding the smallest edge
that connects a vertex in the tree to a vertex outside the tree.
Remove the first element (let's call it 𝑑1) and then subtract 1 from the next
– Sort the degree sequence in non-increasing order (largest to smallest).
Two subgraphs are isomorphic if there exists a bijection between their vertex
sets that preserves adjacency.
Cycle Graph (C_n):The number of non-isomorphic induced subgraphs of a cycle graph C_n depends on
the value of n.For n = 3, there are 4 non-isomorphic induced subgraphs: the empty graph, the single vertex
graph, the path graph P_2, and the cycle graph C_3 it self. For larger values of n, the number of non-
isomorphic induced subgraphs increases.
Path Graph (P_n):The number of non-isomorphic induced subgraphs of a path graph P_n is equal to the
number of partitions of n. For example, P_4 has 5 non-isomorphic induced subgraphs: the empty graph, the
single vertex graph, the path graph P_2, the path graph P_3, and the path graph P_4 itself.
Star Graph (S_n): The number of non-isomorphic induced subgraphs of a star graph S_n is equal to n +
1.This is because the star graph has a central vertex and n leaf vertices. Any subset of the leaf vertices can
form a unique induced subgraph, and there are n + 1 such subsets (including the empty set).
Complete Bipartite Graph (K_{m,n}): The number of non-isomorphic induced subgraphs of a complete
bipartite graph K_{m,n} is quite complex and depends on the values of m and n. In general, it involves
counting the number of ways to partition the vertices into two sets and then considering the possible edges
within each set and between the sets.
Eulerian Graphs
An Eulerian graph: is a graph that has an Eulerian circuit, which is a closed trail that visits every edge
exactly once. In other words, it's possible to start at a vertex, traverse every edge of the graph exactly once,
and return to the starting vertex without repeating any edges.
Eulerian Path: If a graph is not Eulerian but has exactly two vertices of odd degree, it has an Eulerian path,
which is a trail that visits every edge exactly once but doesn't necessarily start and end at the same vertex.
The two vertices of odd degree will be the starting and ending points of the Eulerian path.
Examples :
– Complete Graph (K_n): All complete graphs are Eulerian since every vertex has a degree of n-1,
which is even for any n > 1.
– Cycle Graph (C_n): All cycle graphs are Eulerian as each vertex has a degree of 2.
– Petersen Graph: This well-known graph is not an Eulerian graph because Each vertex in this graph
has a degree of 3, which is odd.
– Eulerian Networks: Many real-world networks, such as transportation networks or street networks,
can be represented as Eulerian graphs if they are connected and all vertices have even degrees. For
example, a postman's route in a city with a connected network of streets can often be represented as
an Eulerian circuit.
Eulerian Graphs – Contd…
1. Euler Graph (Eulerian Graph): A graph is called an Eulerian graph if it contains an Euler circuit, meaning it
is possible to traverse the entire graph and return to the starting point by following each edge exactly once.
For a graph to be Eulerian, all vertices must have an even degree (i.e., an even number of edges connected
to them).
2. Euler Path (Eulerian Path): An Euler path is a path in a graph that visits every edge exactly once, but it
does not necessarily return to the starting point. A graph contains an Euler path if it has exactly two vertices
of odd degree and all other vertices have even degrees.
3. Euler Circuit (Eulerian Circuit): An Euler circuit is a special type of Euler path where the path starts and
ends at the same vertex. It visits every edge of the graph exactly once, forming a closed loop. A graph has
an Euler circuit if and only if all vertices have even degrees.
4. Euler Trail: An Euler trail is another term for an Euler path, emphasizing that the traversal is a trail in which
every edge is visited exactly once. It can start and end at different vertices. Therefore, a graph has an Euler
trail if it contains exactly two vertices of odd degree.
2. Given a graph with 8 vertices and 15 edges, where two vertices have odd degrees (3 and 5),
determine the length of the Eulerian path.
4. Given a graph with 6 vertices and the following degrees: 2, 2, 4, 4, 4, 4, determine if it has an
Eulerian circuit.
5. A city has a street network with 12 intersections. Some intersections have an odd number of streets
connected to them. Determine if it's possible for a postman to deliver mail to every house exactly
once, starting and ending at the post office.
6. Generate a random graph with 10 vertices and 20 edges. Determine if it has an Eulerian circuit.
Bipartite Graphs
A Bipartite Graph is a graph whose vertex set can be divided into two disjoint sets, such that no two
vertices within the same set are adjacent.
Definition: G = (V, E) is bipartite if V can be partitioned into two sets V1 and V2 where every edge
connects a vertex in V1 to one in V2.
Example: Application in scheduling problems where tasks are divided between two independent groups.
Hamiltonian Graphs
A Hamiltonian Graph is a graph that contains a cycle which visits every vertex exactly once (a
Hamiltonian cycle).
Hamiltonian Path: A path that visits each vertex exactly once but does not necessarily return to the
starting point.
Hamiltonian Cycle in a Weighted Graph: The problem of finding the Hamiltonian cycle with the
minimum total weight is a well-known NP (nondeterministic polynomial time)-complete problem.
Traveling Salesman Problem (TSP): It is the problem of finding the Hamiltonian cycle with the minimum
total weight, which is one of the most famous NP-complete problems in computer science and
optimization.
Solution techniques include heuristics and approximation algorithms like Christofides' algorithm.
Hamiltonian Cycles in Weighted
Graphs
A Weighted Graph assigns weights to its edges, often representing costs or distances.
Hamiltonian Cycle in a Weighted Graph: The problem of finding the Hamiltonian cycle with the
minimum total weight is a well-known NP (nondeterministic polynomial time)-complete problem.
Traveling Salesman Problem (TSP): It is the problem of finding the Hamiltonian cycle with the minimum
total weight, which is one of the most famous NP-complete problems in computer science and
optimization.
Solution techniques include heuristics and approximation algorithms like Christofides' algorithm.
Traveling Salesman Problem (TSP)
Description: In the TSP, a salesman must visit a set of cities exactly once and return to the starting city.
Each city is connected to every other city by a road, and each road has a cost (or distance) associated
with it.
The goal is to find a Hamiltonian cycle (a cycle that visits every city once) with the minimum total
weight (the least total travel cost or distance).
Formally, it asks: "Given a complete weighted graph, what is the Hamiltonian cycle with the minimum total
weight?"
Eulerian vs Hamiltonian Graphs
Eulerian Graphs:
Definition: A graph is Eulerian if it contains an Eulerian circuit, which is a cycle that visits every edge
exactly once and returns to the starting vertex.
Key Property: Every vertex in an Eulerian graph must have an even degree (an even number of edges
connected to it).
Conditions:
– A graph has an Eulerian circuit if and only if:
The graph is connected.
Every vertex has an even degree.
Example: A square with diagonals, where you can traverse every edge exactly once, starting and ending
at the same point.
Applications: Eulerian graphs are often used in solving problems related to routing and traversal, such
as the famous Konigsberg Bridge Problem or street-sweeping scenarios.
Eulerian vs Hamiltonian Graphs
Hamiltonian Graphs:
Definition: A graph is Hamiltonian if it contains a Hamiltonian cycle, which is a cycle that visits every
vertex exactly once and returns to the starting vertex.
Key Property: A Hamiltonian graph does not necessarily involve visiting every edge, but it requires
visiting every vertex exactly once.
Conditions:
– There is no simple condition like in Eulerian graphs (even degree rule) to determine whether a
graph is Hamiltonian.
– However, Dirac's Theorem states that if every vertex in a graph with n vertices has a degree of at
least n/2, then the graph is Hamiltonian.
Example: A pentagon where you can visit every vertex exactly once and return to the start.
Applications: Hamiltonian graphs are used in optimization problems like the Traveling Salesman
Problem (TSP), where the goal is to visit every city exactly once with minimal cost.
Eulerian vs Hamiltonian Graphs
Key Differences:
Focus:
– Eulerian graphs focus on covering edges (traversing every edge once).
– Hamiltonian graphs focus on covering vertices (visiting every vertex once).
Conditions:
– Eulerian graphs have a strict rule: all vertices must have even degree.
– Hamiltonian graphs have no such clear rule; it's harder to determine if a graph is Hamiltonian.
Traversal:
– In an Eulerian circuit, you revisit vertices but cover every edge once.
– In a Hamiltonian cycle, you visit every vertex once but might skip some edges.
In summary, Eulerian graphs are about edges, while Hamiltonian graphs are about vertices.
Eulerian vs Hamiltonian -
Problems
1. Given a graph G with vertices A, B, C, D, E, and edges AB, BC, CD, DE, EA, is G a Hamiltonian graph?
2. For a complete graph with 7 vertices, how many Hamiltonian cycles exist?
3. Given a graph G with 6 vertices and 9 edges, is it possible for G to be a Hamiltonian graph?
4. Given a graph G with vertices A, B, C, D, E, and edges AB, BC, CD, DE, EA, is G an Eulerian graph?
5. For a complete graph with 5 vertices, how many Eulerian circuits exist?
6. Given a graph G with 6 vertices and 8 edges, is it possible for G to be an Eulerian graph?
7. Given a graph G with vertices A, B, C, D, E, and edges AB, BC, CD, DE, EA, is G both Hamiltonian and
Eulerian?
8. For a complete graph with 6 vertices, how many graphs are both Hamiltonian and Eulerian?
9. Given a graph G with 7 vertices and 15 edges, is it possible for G to be both Hamiltonian and Eulerian?
10. Given a graph G with 8 vertices and 12 edges, is it possible for G to be both Hamiltonian and Eulerian?
Eulerian vs Hamiltonian -
Problems
1. Given a graph G with vertices A, B, C, D, E, and edges AB, BC, CD, DE, EA, is G a Hamiltonian graph?
2. For a complete graph with 7 vertices, how many Hamiltonian cycles exist?
3. Given a graph G with 6 vertices and 9 edges, is it possible for G to be a Hamiltonian graph?
4. Given a graph G with vertices A, B, C, D, E, and edges AB, BC, CD, DE, EA, is G an Eulerian graph?
5. For a complete graph with 5 vertices, how many Eulerian circuits exist?
6. Given a graph G with 6 vertices and 8 edges, is it possible for G to be an Eulerian graph?
7. Given a graph G with vertices A, B, C, D, E, and edges AB, BC, CD, DE, EA, is G both Hamiltonian and
Eulerian?
8. For a complete graph with 6 vertices, how many graphs are both Hamiltonian and Eulerian?
9. Given a graph G with 7 vertices and 15 edges, is it possible for G to be both Hamiltonian and Eulerian?
10. Given a graph G with 8 vertices and 12 edges, is it possible for G to be both Hamiltonian and Eulerian?
Deterministic vs. Nondeterministic
Computation
1. Deterministic vs. Nondeterministic Computation:
Deterministic computation is what typical computers perform. For a given input, they follow a specific set
of rules or steps to arrive at an output. Algorithms that run on deterministic machines (like normal
computers) process one possible solution path at a time.
For example, if an algorithm has a time complexity of O(n2), where n is the size of the input, it is
considered to run in polynomial time.
Key point: Being in NP doesn’t mean that finding the solution is easy or fast. It only means that checking
a given solution is fast.
Deterministic vs. Nondeterministic
Computation
Examples of NP Problems:
Traveling Salesman Problem (TSP): Given a Hamiltonian cycle (a path visiting all cities), you can easily
compute the total weight and verify whether it's the minimum. But finding that cycle in the first place is
difficult.
Subset Sum Problem: Given a set of numbers, is there a subset that sums to a specific number? If
you’re given a candidate subset, you can quickly sum the elements and verify if it matches the target.
However, finding that subset is computationally hard.
3-SAT: Given a Boolean formula, is there an assignment of truth values (True/False) to variables that
makes the entire formula true? If you’re given an assignment, you can plug it into the formula and check
its validity quickly.
Deterministic vs. Nondeterministic
Computation
4. Relationship Between P and NP:
P (Polynomial Time) is a subset of NP because any problem that can be solved in polynomial time can
also have its solution verified in polynomial time.
The big unresolved question in computer science is whether P = NP. This means:
– Is every problem that can be verified in polynomial time also solvable in polynomial time?
– P ≠ NP: Most computer scientists believe this is true, meaning that there are some problems that
can be verified quickly but cannot be solved quickly.
– P = NP: If this were true, it would imply that all NP problems can be solved just as easily as they
can be verified, revolutionizing fields like cryptography, optimization, and more.
5. NP-Complete Problems:
A problem is NP-complete if:
– It belongs to NP (i.e., its solutions can be verified in polynomial time).
– Every other problem in NP can be transformed (or reduced) to this problem in polynomial time.
NP-complete problems are the hardest problems in NP. If any NP-complete problem can be solved in
polynomial time, then all NP problems can be solved in polynomial time (this would mean P = NP).
Examples: TSP, 3-SAT, Knapsack problem.
Deterministic vs. Nondeterministic
Computation
Summary:
Nondeterministic Polynomial Time (NP) represents problems where, if you had a lucky "guess" or a
"nondeterministic" machine, you could check whether the guess is correct in polynomial time.
The famous P vs NP question asks whether these problems are also easy to solve, not just verify.
In essence, NP focuses on efficient verification, whereas P focuses on both efficient solving and
verification.
Polynomial Time (P)
Polynomial Time (P) is a complexity class in theoretical computer science that describes decision
problems that can be solved by an algorithm in a time that is bounded by a polynomial function of the
input size. This means that as the input size increases, the time required to solve the problem grows at a
relatively slow rate.
Scalability: The problem can be solved efficiently even for large input sizes.
Examples of P problems:
Sorting algorithms: Algorithms like quicksort, mergesort, and bubble sort can sort a list of elements in
polynomial time.
Matrix multiplication: There are efficient algorithms for multiplying matrices in polynomial time.
Graph search algorithms: Algorithms like breadth-first search and depth-first search can find paths in a
graph in polynomial time.
Polynomial Time (P)
Relationship to NP:
P is a subset of NP: Every problem that can be solved in polynomial time can also be verified in
polynomial time. Therefore, P is a subset of NP.
P vs. NP: One of the most famous open problems in computer science is whether P is equal to NP. If P =
NP, it would mean that every NP problem could be solved efficiently, which would have profound
implications for many areas of computer science and mathematics. However, most experts believe that P
≠ NP.
In summary:
Polynomial time: Problems that can be solved efficiently.
Nondeterministic polynomial time: Problems that can be verified efficiently, but finding a solution might
be difficult.
P vs. NP: A fundamental question in computer science about the relationship between these two classes.
Nondeterministic Polynomial Time
(NP)
Nondeterministic Polynomial Time (NP) is a complexity class in theoretical computer science that
describes decision problems that can be verified in polynomial time. This means that if a solution is
provided, its correctness can be checked efficiently. However, finding the solution itself might be
computationally difficult.
Examples of NP problems:
Traveling Salesman Problem: Given a list of cities and the distances between them, find the shortest
possible route that visits each city exactly once and returns to the starting city.
Satisfiability Problem (SAT): Given a Boolean formula, determine if there exists an assignment of truth
values to the variables that makes the formula true.
Clique Problem: Given a graph and an integer k, determine if the graph contains a clique (a subgraph
where every vertex is connected to every other vertex) of size k.
Nondeterministic Polynomial Time
(P)
P vs. NP:
One of the most famous open problems in computer science is whether the class P (problems that can be
solved in polynomial time) is equal to the class NP. If P = NP, it would mean that every NP problem could
be solved efficiently, which would have profound implications for many areas of computer science and
mathematics. However, most experts believe that P ≠ NP.
NP-complete: A problem is NP-complete if it is both NP-hard and in NP. This means that it is as hard as
any other problem in NP.
Many important problems in computer science, such as the Traveling Salesman Problem and the
Satisfiability Problem, are NP-complete.
Graph Embedding in Surfaces
Graph Embedding Embedding a graph in a surface means drawing it on a surface (like a plane or a
sphere) without edge intersections.
– Applications: In networking, surface embeddings help in visualizing complex connections, like internet topologies on a
2D plane or even geographic surfaces.
The maximum number of edges in a simple planar graph with 𝑉 vertices is 3𝑉−6.
– Key Properties:
A complete graph 𝐾5 and a complete bipartite graph 𝐾3,3 are non-planar, serving as important reference points (related
–
–
to Kuratowski's theorem).
Surface Embedding: Involves mapping the graph to surfaces like spheres, tori, or other topological
surfaces.
Applications: Important in fields like circuit board design and geographic information systems (GIS).
Euler’s Formula
Euler's Formula relates the number of vertices V, edges E, and faces F of a connected, planar graph:
V-E+F=2
– V = number of vertices,
– 𝐸= number of edges,
– 𝐹= number of faces (regions bounded by edges, including the outer region).
Applications: Used in topology to determine whether a graph can be embedded in the plane.
Examples: For a triangle, 𝑉=3, 𝐸=3, 𝐹=2; hence, 3−3+2=2. For a cube graph drawn on a plane,
verifying Euler’s formula shows planarity.
Implications: It’s a foundation for checking graph planarity and analyzing graph complexity.
Planar Graphs and Kuratowski’s
Theorem
Planar Graph: A graph that can be drawn in the plane such that no edges cross.
Kuratowski’s Theorem A finite graph is planar if and only if it contains no subgraph that is
homeomorphic to K5 (complete graph on 5 vertices) or K3,3 (complete bipartite graph on 6 vertices).
Applications: Critical in the design of electronic circuits, where planarity minimizes crossings between
connections.
Dual of Planar Graphs
The Dual Graph of a planar graph is constructed by placing a vertex in each face of the graph and
connecting two vertices if their corresponding faces share an edge.
Properties:
– Vertices and Faces Correspondence: Each face of the original graph corresponds to a vertex in the
dual graph.
– Edges: Each edge in the original graph corresponds to an edge in the dual graph.
– Planarity: The dual of a planar graph is also planar.
– Dual of a Dual: The dual of the dual graph is isomorphic to the original graph.
Example: Dual graphs are used in geographic mapping and mesh generation for 3D modeling.
Construction:
– Prerequisites:
– The graph must be planar and embedded in the plane, meaning its edges are drawn without any
crossings.
– A face is a region bounded by edges, including the outer infinite region.
Construction of Dual Graphs
Place a vertex inside each face of the planar graph:
– This includes one vertex for the outer (infinite) face.
Ensure no crossings:
– Draw the dual edges so that they cross their corresponding original edges but no others.
Examples: Max-Flow Min-Cut Theorem: The maximum flow in a network is equal to the minimum cut
separating the source and sink.
Applications: Common in sensor networks and strategic positioning problems (e.g., placing signal towers
to cover a region).
Maximum Bipartite Matching
Bipartite Graph: Vertices can be divided into two disjoint sets U and V such that every edge connects a
vertex in U to one in V.
Applications: Scheduling (where conflicts are edges), map coloring, and register allocation in compilers.
Properties:
– For small k, determines the feasibility of a given coloring.
Applications: Efficient for certain algorithms, like tree decompositions, and widely used in database
management systems.
Powers of Graphs
Definition: The k-th power Gk of a graph G connects vertices if they are at most k edges apart in G.