0% found this document useful (0 votes)
5 views78 pages

Complex Networks - Introduction to Graph Theory Lecture-2

This document provides an introduction to graph theory, covering fundamental concepts such as graphs, nodes, edges, and various types of graphs including simple, bipartite, and Eulerian graphs. It discusses properties of graphs, methods for constructing spanning trees, and the Travelling Salesman Problem, highlighting the importance of these concepts in network design and optimization. Additionally, it introduces algorithms for finding Eulerian and Hamiltonian paths, emphasizing their applications in real-world scenarios.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views78 pages

Complex Networks - Introduction to Graph Theory Lecture-2

This document provides an introduction to graph theory, covering fundamental concepts such as graphs, nodes, edges, and various types of graphs including simple, bipartite, and Eulerian graphs. It discusses properties of graphs, methods for constructing spanning trees, and the Travelling Salesman Problem, highlighting the importance of these concepts in network design and optimization. Additionally, it introduces algorithms for finding Eulerian and Hamiltonian paths, emphasizing their applications in real-world scenarios.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 78

Complex Networks

Lecture 2: Introduction to Graph Theory

GE 2318
Instructor: G Ron Chen

Acknowledgement: Un-copyrighted photos and pictures were taken from the Internet
What is a Graph?

A graph is a diagrammatical
representation of some physical
structure
such as:
a circuit
a computer network
a human relation network
… and so on
Example
Euler (1707-1783) proved that the Königsburg
seven- bridge problem has no solution
Notation and Terminology
▪ In a graph, a node has no size and an edge has no width and length

▪ Let 𝐺 be a non-empty graph with at least one node (or vertex)

▪ In a graph 𝐺 with non-isolated nodes, there is at least one edge


(or link, or connection); thus, it has at least two nodes

▪ The graph 𝐺 is referred to as a simple graph


B

A C D
Examples of General (non-simple) Graphs

5 2
weighted graphs
sometimes considered
1

graph with self-loop


or multiple edges
are not allowed

Convention: not allowed

When a node is removed, all its edges are also removed


Examples of Simple Graphs
B

node set = A, B, C, D


edge set = AB, AC, BC, CD
A C D

Subgraph: 𝐴𝐵, 𝐴𝐵𝐶, 𝐷 etc. (needed not be connected, e.g., AB with D)


Circuit (cycle, loop): 𝐴𝐵𝐶
Component: A self-connected subgraph, but un-connected with other
parts of the same graph

 A simple graph with 3 components


Some Basic Properties

Property:

A simple graph 𝐺 with 𝑁 nodes has at most 𝑁(𝑁−1)/2 edges

Reasoning:

N-1 Examples:

1
Some Basic Properties
• Property:
The total node degree of a graph is always an even number.

• Reasoning: Since every edge joins two nodes, so the total


node degree is twice of the number of edges.

• Property:
In a graph, the number of nodes of odd degrees must be even.

Examples:
Density of Graph

Existing Edges
Maximum possible
total number of edges

Existing
Edges
Existing
Edges

𝑎21 + 𝑎31 + 𝑎51 + 𝑎32 + 𝑎42 5 1


𝐷𝑒𝑛 = = =
5(5 − 1)/2 10 2
Adjacency Matrix
• For a graph 𝐺 with nodes 𝑁 𝐺 = {1,2, … , 𝑛}, its adjacency
matrix 𝐴 is defined to be the 𝑛 × 𝑛 constant matrix, where
the 𝑖𝑗th entry is 1 if node 𝑖 connects node 𝑗, or 0 otherwise.

• Example:
1 2 3 4
1 2 1 01 0 1
2 10 1 1 
A= 

3 0 1 0 1

 
4 1 1 1 0
4 3

(always square and symmetrical)

Computer/algorithm uses the adjacency matrix to store a network


Example

The new A can


be obtained by
exchanging the
A=? 4th and 5th rows
and 4th and 5th
columns of the
original A
Incidence Matrix
• For a graph 𝐺 with edges 𝑀 𝐸 = {1,2, … , 𝑚}, its incidence
matrix 𝑀 is defined to be the 𝑛 × 𝑚 constant matrix, where
the 𝑖𝑗th entry is 1 if node 𝑖 connects edge 𝑗, or 0 otherwise.

• Example:
1 2 3 4 5
1 1 2
11 0 0 1 0
21 1 0 0 1
M =
5
4 2
3 0 1 1 0 0
 
4 3 3 4 0 0 1 1 1

(generally non-square)
A graph may take different shapes
A graph may take different shapes
Bipartite Graphs
Bipartite Graphs
Bipartite Graphs

?
Tripartite Graphs
Tripartite Graph: All nodes are partitioned into three sets
in such a way that no two nodes contained in any one of
the three parts are adjacent
Trees
▪ Tree: A connected graph without any loop
▪ Forest: A family of unconnected trees

▪ A tree with 𝑁 nodes has exactly 𝑁 − 1 edges


▪ Total node degrees of a tree
= 2 x (number of edges) = 2(𝑁 − 1)
Trees-like

Trees
Bridges
Bridge: An edge, whose removal will disconnect the network

Example: Edge e below is a bridge

Every edge in a tree is a bridge


Importance of bridges
In a network, a node of low degree may be more important
than a node of high degree; for example, on a bridge:
Maze

A simple path in a
maze is a chain
Or, at most,
including those
unsuccessful
attempts, is a tree
All loops are
redundant and
can be removed
Maze
A simple algorithm to build a maze
(1) Start with a grid that has every possible wall filled in
(2) Choose a boundary cell to begin
(3) From the current cell:
(3.1) If there are unvisited neighbors, randomly choose
one to move in
(3.2) If there are no unvisited neighbors, backtrack to the
previous cell, and search for an unvisited neighbor
(4) Continue till end
Explanation
Example
A
More about Trees

▪ Spanning tree of a graph 𝐺 B E

is a subgraph that is a tree


that connects all nodes of 𝐺
C D

▪ Spanning tree may not be A

unique

B E

For example →
Two spanning
trees of a graph
C D
Minimum Connector Problem
▪ Minimum connector problem: Suppose that one
wants to build a highway network connecting some
cities, in such a way that a car can traverse from any
city to any other city but the total mileage of the
highways is minimum

▪ Solution must be a spanning tree A

2 6

▪ The problem is to find 6

a spanning tree with B 4


E
8
minimum total length 5
8 3
7

▪ Solution may not be unique


C D
9
Method 1
Staring from the shortest edge

→ Keep this edge


A

2 6

6
E
B 4
8
5
8 3
7

C D
9
Method 1
Continue → Next shortest edge

2 6

6
E
B 4
8
5
8 3
7

C D
9
Method 1
Continue → Next shortest edge

2 6

6
E
B 4
8
5
8 3
7

C D
9
Method 1
Continue → Next shortest edge

Avoid loops ! A

2 6

6
E
B 4
8
5
8 3
7

Note: BD = 5 or
AE = 6 or BE= 6
C D
will form a circuit 9
Result

Finally → Best spanning tree

A
6
2

6
B E
4
8
5 8
7 3
No more edge
can be added
C 9 D
Method 2
Staring from the longest edge
Remove the edge to break loop

2 6

6
E
B 4
8
5
8 3
7

C D
9
Method 2
Staring from the longest edge
Remove the edge to break loop

2 6

6
E
B 4
8
5
8 3
7

C D
Method 2
Staring from the longest edge
Remove the edge to break loop

2 6

6
E
B 4
8
5
3
7

C D
Method 2
Staring from the longest edge
Remove the edge to break loop

2 6

6
E
B 4

5
3
7

C D
Method 2
Staring from the longest edge
Remove the edge to break loop

2 6

E
B 4

5
3
7

C D
Method 2
Staring from the longest edge
Remove the edge to break loop

E
B 4

5
3
7

C D
Method 2
Staring from the longest edge
Remove the edge to break loop

E
B 4

3
7

C D
Result

Finally → Best spanning tree

A
6
2

6
B E
4
8
5 8
7 3
No more edge
can be removed
C 9 D
BREAK
10 minutes
Eulerian Graphs

Eulerian graph:

A graph is a Eulerian graph if and only if one can walk


through every edge once and once only and then return
to the starting node

Property:
A graph is Eulerian if and only if All notes have even degrees

Examples:
Semi-Eulerian Graphs
Semi-Eulerian graph:

A graph is a semi-Eulerian graph if and only if


one can walk through every edge once and
once only and then return to the starting node

▪ Examples: Seven bridge problem


Eulerian
Example:
Example
(path usually not unique)
Algorithm to find Eulerian Graphs

▪ Fleury Algorithm: In any given Eulerian graph 𝐺,


to find an Eulerian trail:
▪ Start from any node in 𝐺 (will come back)
▪ Walk along the edges of 𝐺 in any manner,
subject to the following rules:
> erase the edges as they are traversed;
> erase the resulting isolated nodes;
▪ walk through a bridge only if there are no other
alternatives.
Example:
Chinese Postman Problem
• The problem is for a postman to deliver letters in
such a way that he passes every street (where
there are many homes) at least once and finally
returns to the starting point (the post office),
traversing a shortest possible total path-length.
• First solution given by Prof Mei-ko Kwan (1934—)
(管梅谷 from Shanghai)
Chinese Postman Problem

Ideas:
To have a solution, the graph must be Eulerian
Example:
Steps:
(1) Make the graph be Eulerian by adding edges Post Street
Office
to nodes with odd degrees (sometimes also
some nodes with even degrees) Solution:

(2) Compare all choices: the smallest total length


of the added edges is an optimal solution
Example:

d 8 c
o o
5 5

6 6
5 Post 5
Office  The center
node had an
a 8 b even degree.
After adding
o repeated
(a) streets, it
should still
have an even
degree.
(b) Add:
8
5
6 ab + dc = 8 + 8 = 16
o o
(c) Add:

ad + bc = 6 + 6 = 12

(d) Add:

o ao + bo + co + do
=5+5+5+5
= 20
Kuan Mei-Ko (2016)
Sir William Rowan Hamilton (1805-1865)
In 1856, the English mathematician William R. Hamilton
studied the world navigation problem and considered a
map with 20 nodes representing cities connected by
sailing routes, as depicted by the following figure. He
wanted to find out if one can traverse through every city
once and once only, and finally return to the starting city.
His study eventually led to the establishment of the now-
famous Hamiltonian graph theory.
One solution
Another Example
Hamiltonian Graphs

Hamiltonian graph:

A graph is a Hamiltonian graph if and only if one


can walk through every node once and once
only and then return to the starting node

▪ Examples:
Semi-Hamiltonian Graphs

Semi-Hamiltonian graph:

A graph is a semi-Hamiltonian graph if and only if


one can walk through every node once and once
only and then return to the starting node

Examples:
Travelling Salesman Problem

Travelling Salesman Problem -


Given a set of cities and the distances between each
pair of cities, what is the shortest possible route that
visits every city once and once only, and then returns
to the starting city?

It is called an optimal Hamiltonian graph problem,


which is NP-hard

A special case: The given cities are fully connected

Fully-connected graph is also called complete graph


Travelling Salesman Problem: On fully-connected graphs

Nearest-Neighbor Algorithm: To find a near-optimal solution

Start with an arbitrary node, 𝑣0 . Find one adjacent edge with


the smallest weight, which connects to node 𝑣1 , so as to have
𝑣0 − 𝑣1
Start with 𝑣1 , repeat the same process, … until having
𝑣0 − 𝑣1 − ⋯ − 𝑣𝑛
If 𝑣𝑛 still has nearest neighbor(s) not traversed, then continue;
If 𝑣𝑛 does not have anymore nearest neighbor not traversed,
then connect 𝑣𝑛 back to 𝑣0

Solution: 𝑣0 − 𝑣1 − ⋯ − 𝑣𝑛 − 𝑣0
Travelling Salesman Problem: A fully-connected graph

Example:
A
9 12
7
E 9 B 10

13 5
8
6

D 11 C

Start from A

A → D → B → C → E → A (This is a loop)

Total path length = 7 + 6 + 8 + 5 + 9 = 35


Q: If you start from another node, say C, will you get the same result?
A: Maybe not

C → E → A → D → B → C (Total path length = 5 + 9 + 7 + 6 + 8 = 35)


Same as above

However:
C → E → B → D → A → C (Total path length = 5 + 9 + 6 + 7 + 10 = 37)
Example of TSP for Optimal Design
Is this a (semi)-Hamiltonian graph ?
Knight’s Tour Game
Can the knight visit every block, once and once
only, and finally return to the starting point?

5 X 5 has open solution (semi-Hamiltonian)


but no closed solution (Hamiltonian)
8 X 8 – Yes, it always has a closed solution
Namely, it is Hamiltonian, proved by Euler (1759)
8 X 8 – Yes, it is Hamiltonian
This shows one solution
Note:
Even if there is always a solution, it does not
mean that starting anywhere will be a solution
(Reason: 8X8 is a square but the walking step
of a knight is not square)
24 x 24
Summary

Eulerian Graph:

One can traverse through every edge once and once


only, and then return to the starting node

Hamiltonian Graph:

One can traverse through every node once and once


only, and then return to the starting node

If not return then it is Semi-


Directed Graphs
Digraph (= directed graph): edge 𝑢, 𝑣 : 𝑢 ← 𝑣
v
simple digraph
u

Underlying graph: (May not be well defined)

non-simple graph

double connection
Degrees
In-degree: 𝑑𝑖𝑛
Out-degree: 𝑑𝑜𝑢𝑡
Total degree: 𝑑 = 𝑑𝑖𝑛 + 𝑑𝑜𝑢𝑡
Balanced: 𝑑𝑖𝑛 = 𝑑𝑜𝑢𝑡

The following can be similarly defined:

➢ Directed path
➢ Directed cycle (loop)
➢ Directed tree
➢ Directed Eulerian graph
➢ Directed Hamiltonian graph
Connectivity
A digraph is (weakly) connected if its underlying graph is
connected.
A digraph is strongly connected if there is a directed path
from any node to any other node.
1
4
 connected but not strongly connected
2 3

1
4
 strongly connected
2 3
Adjacency Matrix

1 0 1 0 0
4 0 0 1 0
Ad = [aij ] =  (asymmetric)
2 3 1 1 0 0
 
0 0 1 0
aij -- from i to j

Underlying network
A is not well-defined
due to multiple edges
Incidence Matrix

1 If a node is at the head of a directed edge,


4
a b e then give it a value 1.
c
2 3 If a node is at the tail of a directed edge,
d then give it a value −1.
If a node does not belong to an edge, then
give it a value 0.
𝑎 𝑏 𝑐 𝑑 𝑒
1 −1 1 0 0 0
𝑀𝑑 = 2 1 0 −1 1 0
3 0 −1 1 −1 1
4 0 0 0 0 −1
Directed Tree

A directed tree is a directed graph without any directed cycle


and its underlying graph is a tree
Directed and Weighted Networks

Applications: coding, high-security computer networks


(data diode), Industrial control systems, …
End

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy