SlideShare a Scribd company logo
1 of 58
Download to read offline
88
Matrix Operations
▷ 1 ▷ Computational Problem Solving
88
A matrix (plural: matrices) is simply an ‘array’ of numbers, e.g.
But the power of matrices comes from being able to multiply matrices by vectors
and matrices by matrices and ‘invert’ them: we can:
1. represent linear transformations using matrices (e.g. rotations, reflections
and enlargements)
2. Use them to solve linear simultaneous equations.
The first of these means matrices are particularly useful in 3D
graphics/animation, since they allow us to rotate the camera and project 3D
data onto a 2D viewing plane. But matrices are used everywhere, including
robotics, computer vision, optimisation, classical and quantum mechanics,
electromagnetism, optics, graph theory, statistics, ...
On a simple level, a matrix is simply a way to organise values into rows and columns,
and represent these multiple values as a single structure.
▷ 2 ▷ Introduction to matrices
88
The zero matrix, 𝑍 or 𝟎 is the matrix with zero as each element.
The identity matrix is the matrix with ones on its main diagonal.
The 2x2 identity matrix is 𝐼 =
1 0
0 1
And has the property that 𝐼𝐴 = 𝐴𝐼 = 𝐴
In general, matrix multiplication is not commutative, i.e. 𝐴𝐵 ≠ 𝐵𝐴
It is, however, associative, i.e. 𝐴 𝐵𝐶 = 𝐴𝐵 𝐶
▷ 3 ▷ Introduction to matrices
88
The dimension of a matrix is its size, in terms of its number of rows and columns.
2  3
3  1
1  3
A matrix can have square or curvy brackets*.
Matrix Column Vector
(The vector you know
and love)
Row Vector
So a matrix with one column is simply a vector in the usual sense.
▷ 4 ▷ Introduction to matrices
88
If we wish a variable to represent a matrix, we use bold, capital letters.
𝑨 =
1
6
−3
𝑪 = 𝑷−𝟏𝑻𝑷
Each value within a matrix is known as an element.
If A is a matrix, then we can refer to the element in the ith row and jth
column as 𝑎𝑖,𝑗.
𝑐1,2 = 3 𝑐2,1 = 4 𝑐1,3 = −7
▷ 5 ▷ Introduction to matrices
88
Simply add/subtract the corresponding elements of each matrix.
They must be of the same dimension.
▷ 6 ▷ Adding/Subtracting Matrices
88 ▷ 7 ▷ Vectors
A row vector is a 1 × 𝑛 matrix and a column vector is a
𝑛 × 1 vector. Vectors have similar properties to matrices
(in terms of addition and subtraction) although have their
own form of multiplication.
There are two ways to multiply vectors – dot product and
cross product. We only look at dot product which is (for a
3D vector)
𝑎
𝑏
𝑐
⋅
𝑥
𝑦
𝑧
= 𝑎𝑥 + 𝑏𝑦 + 𝑐𝑧
For example:
1
4
⋅
2
−1
= 1 × 2 + 4 × −1 = 2 − 4 = −2
88
A scalar is a number which can ‘scale’ the elements inside a matrix/vector.
1
2
3
▷ 8 ▷ Scalar Multiplication
88
This is where things get slightly more complicated...
1 0 3 -2
2 8 4 3
7 -1 0 2
5 1
1 7
0 3
8 -3
-11
We start with this row and
column, and sum the products
of each pair.
(1 x 5) + (0 x 1) + (3 x 0) + (-2 x
8) = -11
This is known as finding the
“dot/scalar product” of the two
vectors.
16
Now repeat for the next row of the left matrix...
42 61
50 -6
▷ 9 ▷ Matrix Multiplication
88
=
1 2 3
1
2
3
= 14
1
2
3
1 2 3 =
1 2 3
2 4 6
3 6 9
a
b
c
d
e
f
▷ 10 ▷ Matrix Multiplication
88
Matrix multiplications are not always valid: the dimensions have to agree.
Note that only square matrices (i.e. same width as height) can be raised to a power.
Dimensions of A Dimension of B Dimensions of AB (if valid)
2  3 3  4 2  4
1  3 2  3 Not valid.
6  2 2  4 6  4
1  3 3  1 1  1
7  5 7  5 Not valid.
10  10 10  9 10  9
3  3 3  3 3  3
▷ 11 ▷ Matrix Multiplication
88
The transpose of a matrix is formed by swapping the columns and row.
For example, if 𝐴 =
𝑎 𝑏
𝑐 𝑑
, then 𝐴𝑇
=
𝑎 𝑐
𝑏 𝑑
The determinant of a 2x2 matrix is 𝑎𝑑 − 𝑏𝑐, written as det 𝐴 = 𝑎𝑑 − 𝑏𝑐. The inverse is:
𝐴−1
=
1
𝑎𝑑 − 𝑏𝑐
𝑑 −𝑏
−𝑐 𝑎
We can use this to solve simultaneous equations
i.e.
𝑎𝑥 + 𝑏𝑦 = 𝑒
𝑐𝑥 + 𝑑𝑦 = 𝑓
Becomes 𝐴𝑥 = 𝑏 or
𝑎 𝑏
𝑐 𝑑
𝑥
𝑦 =
𝑒
𝑓
Which means that: 𝑥 = 𝐴−1
𝑏, or
𝑥
𝑦 =
𝑎 𝑏
𝑐 𝑑
−1 𝑒
𝑓
▷ 12 ▷ Matrix transpose / Inverse
88 13
88
Graphs and Trees
▷ 14 ▷ Computational Problem Solving
88 ▷ 15 ▷ Applications
Graph theory is important to find:
a) Shortest distance between two points
b) Search engine optimisation
c) Communications
d) Travelling salesperson problem
e) Graph colouring (used for parallel computing)
f) Data science
88 ▷ 16 ▷ Introduction
Graph theory is not about the sort of graphs you did at school!
88 ▷ 17 ▷ Applications
88 ▷ 18 ▷ What is a graph?
1. A graph is a set of vertices (V) and
edges (E)
2. Each edge in E has two endpoints
which connect two elements of V
(Possibly the same element)
3. In an undirected graph, edges have
no specific direction, and can be
considered to connect a to b or b to
a
4. In a directed graph, edges do have a
specific direction
5. The number of endpoints at a vertex
is called the degree of that vertex
88 ▷ 19 ▷ Representing Graphs
We can represent a graph with a
diagram.
The vertices are blobs
Undirected edges are lines
a
b
c
e
d
g
f
88 ▷ 20 ▷ Representing Graphs
We can represent a graph with a
diagram.
The vertices are blobs
Undirected edges are lines
Directed edges are arrows
a
b
c
e
d
g
f
88
Definition
▷ 21 ▷ Terminology
The degree of a vertex in an undirected graph is the
number of edges incident to it, except that a loop
contributes twice to the degree.
The degree of a vertex 𝑣 is denoted by deg(𝑣)
deg 𝑎 = 2
deg 𝑏 = 4
deg 𝑔 = 0
For any graph 𝐺 the sum of the degrees for all vertices equals to the number of edges
multiplied by two.
That is, 2𝑚 = σ𝑣∈𝑉 deg(𝑣) where 𝑚 is the number of edges in the graph 𝐺 = (𝑉, 𝐸)
88
My Turn Your Turn
▷ 22 ▷ Degrees of Vertices Example
Find the number of vertices, the number of edges and
the degree of each vertex in the given undirected
graph. Identify all isolated and pendant vertices.
𝑣 = 6
𝑒 = 6
deg 𝑎 = 2
deg 𝑏 = 4
deg 𝑐 = 1
deg 𝑑 = 0
deg 𝑒 = 2
deg 𝑓 = 3
𝑐 is pendant (vertex has degree 1) and 𝑑
is isolated (vertex has degree 0).
Find the number of vertices, the number of edges and
the degree of each vertex in the given undirected
graph. Identify all isolated and pendant vertices.
𝑣 = 5
𝑒 = 12
deg 𝑎 = 5
deg 𝑏 = 6
deg 𝑐 = 5
deg 𝑑 = 5
deg 𝑒 = 3
There are no isolated or pendent vertices as
none of the vertices have degree 0 or 1
88 ▷ 23 ▷ Handshaking Lemma
Every edge has two endpoints
The sum of all the endpoints in a
graph must be even.
If there are n edges, there must be
2𝑛 endpoints
This is known as the "Handshaking
Theorem"
The sum of all the endpoints in a
graph is equal to the sum of all the
vertex degrees
The sum of all vertex degrees must
be even
෍
𝑣∈𝑉
deg 𝑣 = 2|𝐸|
෍
𝑣∈𝑉
deg 𝑣
= deg 1 + deg 2 + deg 3 + deg 4 + deg 5 + deg(6)
= 2 + 3 + 2 + 3 + 3 + 1 = 14
2 𝐸 = 2 × 7 = 14 (7 edges in the graph)
88
Definition
▷ 24 ▷ Definition of Graph Using Sets
We can represent graphs with sets
G = (V, E)
V = set of vertices, e.g {a,b,c,d,e}
E = set of edges
• e.g. Undirected: E = { {a,b}, {b,c}, {d,e} }
• e.g. Directed: E = { (a,b), (b,c), (d,e) }
88
Definition
▷ 25 ▷ Simple graphs
A graph in which each edge connects two different
vertices and where no two edges connect the same pair of
vertices is called a simple graph
A simple graph: And not simple:
What makes the simple graph different to a non-simple graph?
88
Definition
▷ 26 ▷ Simple Graph
Simple Graph
• Simple graphs are UNDIRECTED
• Edges connect two different vertices
• So no loops on vertices
• Maximum of one edge between any pair of vertices
Simple Directed Graph
• Same – but edges are directed
NOTE: To avoid confusion this
module will standardise on
the common definition of a
simple graph as UNDIRECTED
(as found in Rosen)
88
Definition Characteristics
Examples Non-Examples
▷ 27 ▷ Frayer Diagram
Simple
Graph
a simple graph is an unweighted, undirected graph
containing no loops or multiple edges. It can be either
connected or disconnected
88
• An undirected graph is connected if there is at least one path
between any two vertices
• A directed graph is strongly connected if there is at least one path
between any two vertices that follows all the directions of the edges
• A directed graph is weakly connected is there is at least one path
between any two vertices that ignores all the directions of the edges
88
• A bridge is an edge which, if removed, would cause the graph to
become disconnected
a c
b
d
f
e
88
• A graph that is not connected has two or more connected
components.
• These components are disjoint
• The union of all components is the original graph
a c
b
d
f
e
88
Definition
▷ 31 ▷ Adjacency List
A table with 1 row per vertex, listing its adjacent vertices.
a b
d
c
f
e
Vertex
Adjacent
Vertices
a
b
b, c
a, c, e, f
c a, b, f
d
e b
f c, b
88
Definition
▷ 32 ▷ Adjacency Matrix
A way to represent simple graphs
• possibly with self-loops.
Matrix A=[aij], where aij is 1 if {vi, vj} is an edge of G, and is
0 otherwise.
Can extend to pseudographs by letting each matrix
elements be the number of links (possibly >1) between the
nodes.
88
Examples
▷ 33 ▷ Adjacency Matrix – Undirected
0
1
7
2
5
3
4
6
88
Examples
▷ 34 ▷ Adjacency Matrix – Directed
1
2
3
4
88
My Turn Your Turn
▷ 35 ▷ Adjacency Matrix Example
0
0
1
0
0
0
6
0
0
1
0
1
1
5
1
1
0
1
0
0
4
0
0
1
0
1
0
3
0
1
0
1
0
1
2
0
1
0
0
1
0
1
6
5
4
3
2
1
0
2
0
1
1
5
2
0
0
1
1
4
0
0
0
0
0
3
1
1
0
0
2
2
1
1
0
2
0
1
5
4
3
2
1
1 2
3
4
5
88 ▷ 36 ▷ Graph representation
Adjacency matrices:
Incidence matrices:
0 1 1 0
1 0 0 1
1 0 0 1
0 1 1 0
𝑎 𝑏 𝑐 𝑑
𝑎
𝑏
𝑐
𝑑
88
• The complete graph Kn
• For any nN, a complete graph on n vertices, Kn, is a simple graph
with n nodes in which every node is adjacent to every other node:
u,vV: uv{u,v}E.
• A set of n vertices – all connected to each other
K1 K2
K3
K4
K5 K6
Note that Kn has edges.
2
)
1
(
1
1
−
=

−
=
n
n
i
n
i
88
• The cycle graph Cn
• A set of n vertices (n ≥3) { c1, c2, c3, … , cn }
• A set of edges { {c1,c2}, {c2,c3}, {c3, c4}, …, {cn-1, cn} }
C3 C4 C5 C6 C7
C8
How many edges are there in Cn?
88
• The wheel graph Wn
• A set of n+1 vertices (n ≥4) { v, c1, c2, c3, … , cn }
• A set of edges { {c1,c2}, {c2,c3}, {c3, c4}, …, {cn-1, cn} }
∪
{ {v,c1}, {v,c2}, {v,c3}, …, {v, cn} }
• For any n3, a wheel Wn, is a simple graph obtained by taking the cycle Cn
and adding one extra vertex vhub and n extra edges {{vhub,v1},
{vhub,v2},…,{vhub,vn}}.
W3 W4 W5 W6 W7
W8
How many edges are there in Wn?
88
• The n-cube Qn
• A set of 2n vertices
• Each vertex represents a bit string
• A set of edges
• Each edge connects two vertices that differ by one bit
Q0
Q1 Q2 Q3
Q4
Number of vertices: 2n. Number of edges:Exercise to try!
88
• To draw the n-cube Qn
• Start with Q1
• Duplicate it
• Prefix the original vertices with "0"
• Prefix the duplicate vertices with "1"
• Connect the corresponding vertices
00 01
10 11
88
• To draw the n-cube Qn
• Start with Q2
• Duplicate it
• Prefix the original vertices with "0"
• Prefix the duplicate vertices with "1"
• Connect the corresponding vertices
000 001
010 011
100 101
110 111
88
• A graph is bipartite if its vertices can be divided into two subsets, so
that every edge connects a vertex in one subset to a vertex in the
other.
• Here the subsets are {a,b,c} and {d,e}
a b c
d e
88
• A graph is bipartite if its vertices can be divided into two subsets, so
that every edge connects a vertex in one subset to a vertex in the
other.
• Here the subsets are {a,b,c} and {d,e}
a b c
d e
88
• A bipartite graph is complete if every edge in one subset is connected
to every edge in the other
• The complete bipartite graph of m vertices in one subset and n
vertices in the other is denoted Km,n
a b c
d e
This is the complete
bipartite graph K3,2
K4,3
Km,n has _____ nodes
and _____ edges.
88
• Diagrams can be drawn anyhow
• Vertices can go anywhere
• Lines can cross (and in some cases, must cross)
• With practice, you'll discover how to improve neatness.
88 ▷ 47 ▷ Special simple graphs
A complete graph on 𝑛 vertices 𝐾𝑛
A cycle 𝐶𝑛 𝑛 ≥ 3
A wheel 𝑊
𝑛
88 ▷ 48 ▷ Bipartite graphs
A simple graph 𝐺 is called bipartite if its vertex set 𝑉 can
be partitioned into two disjoint sets 𝑉1 and 𝑉2 such that
every edge in the graph connects a vertex in 𝑉1 and a
vertex in 𝑉2
𝐾𝑚,𝑛: a complete bipartite graph with 𝑉1 = 𝑚 and
𝑉2 = 𝑛
88 ▷ 49 ▷ Graph isomorphism
Informally (you will see a formal definition of graph
isomorphism later during the course):
There is a useful terminology for graphs with the same
structure
88 ▷ 50 ▷ Graph isomorphism
Which graphs are isomorphic?
88
Classification
Simple ?
Connected ?
Directed ?
Multigraph ?
Kn ?
Cn ?
Bipartite ?
Km,n ?
Classification
Simple ✓
Connected ✓
Directed 
Multigraph 
Kn ✓ K3
Cn ✓ C3
Bipartite 
Km,n 
a c
b
88
Classification
Simple ?
Connected ?
Directed ?
Multigraph ?
Kn ?
Cn ?
Bipartite ?
Km,n ?
Classification
Simple 
Connected ✓Strong
Directed ✓
Multigraph 
Kn 
Cn 
Bipartite 
Km,n 
a b
NOTE: To avoid confusion this
module will standardise on
the common definition of a
simple graph as UNDIRECTED
(as found in Rosen)
88
Classification
Simple ?
Connected ?
Directed ?
Multigraph ?
Kn ?
Cn ?
Bipartite ?
Km,n ?
Classification
Simple ?
Connected ?
Directed ?
Multigraph ?
Kn ?
Cn ?
Bipartite ?
Km,n ?
Classification
Simple 
Connected 
Directed 
Multigraph 
Kn 
Cn 
Bipartite 
Km,n 
a c
b
88
Classification
Simple ?
Connected ?
Directed ?
Multigraph ?
Kn ?
Cn ?
Bipartite ?
Km,n ?
Classification
Simple 
Connected ✓ Weak
Directed ✓
Multigraph 
Kn 
Cn 
Bipartite 
Km,n 
a b
c
d e
88
Classification
Simple ?
Connected ?
Directed ?
Multigraph ?
Kn ?
Cn ?
Bipartite ?
Km,n ?
Classification
Simple ✓
Connected 
Directed 
Multigraph 
Kn 
Cn 
Bipartite 
Km,n 
a c
b
88
Classification
Simple ?
Connected ?
Directed ?
Multigraph ?
Kn ?
Cn ?
Bipartite ?
Km,n ?
Classification
Simple ✓
Connected ✓
Directed 
Multigraph 
Kn 
Cn 
Bipartite ✓
Km,n ✓K2,4
a
c d e f
b
88
Classification
Simple ?
Connected ?
Directed ?
Multigraph ?
Kn ?
Cn ?
Bipartite ?
Km,n ?
Classification
Simple ✓
Connected ✓
Directed 
Multigraph 
Kn 
Cn ✓ C4
Bipartite ✓
Km,n ✓ K2,2
a c
b d
88
Classification
Simple ?
Connected ?
Directed ?
Multigraph ?
Kn ?
Cn ?
Bipartite ?
Km,n ?
Classification
Simple ✓
Connected ✓
Directed 
Multigraph 
Kn 
Cn ✓ C4
Bipartite ✓
Km,n ✓ K2,2
a c
b d

More Related Content

Similar to Lecture_1_matrix_operations.pdf

Matrix Algebra : Mathematics for Business
Matrix Algebra : Mathematics for BusinessMatrix Algebra : Mathematics for Business
Matrix Algebra : Mathematics for BusinessKhan Tanjeel Ahmed
 
Graphs in datastructures
Graphs in datastructuresGraphs in datastructures
Graphs in datastructuresLikhithaGunturi
 
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringGraph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringSaurabh Kaushik
 
Brief review on matrix Algebra for mathematical economics
Brief review on matrix Algebra for mathematical economicsBrief review on matrix Algebra for mathematical economics
Brief review on matrix Algebra for mathematical economicsfelekephiliphos3
 
Matrices and determinants
Matrices and determinantsMatrices and determinants
Matrices and determinantssom allul
 
Mathematics fundamentals
Mathematics fundamentalsMathematics fundamentals
Mathematics fundamentalsSardar Alam
 
Matrices and its Applications to Solve Some Methods of Systems of Linear Equa...
Matrices and its Applications to Solve Some Methods of Systems of Linear Equa...Matrices and its Applications to Solve Some Methods of Systems of Linear Equa...
Matrices and its Applications to Solve Some Methods of Systems of Linear Equa...Abdullaا Hajy
 
Matrices and its Applications to Solve Some Methods of Systems of Linear Equa...
Matrices and its Applications to Solve Some Methods of Systems of Linear Equa...Matrices and its Applications to Solve Some Methods of Systems of Linear Equa...
Matrices and its Applications to Solve Some Methods of Systems of Linear Equa...Rwan Kamal
 
University of duhok
University of duhokUniversity of duhok
University of duhokRwan Kamal
 
matrix-algebra-for-engineers (1).pdf
matrix-algebra-for-engineers (1).pdfmatrix-algebra-for-engineers (1).pdf
matrix-algebra-for-engineers (1).pdfShafaqMehmood2
 
ALLIED MATHEMATICS -I UNIT III MATRICES.ppt
ALLIED MATHEMATICS -I UNIT III MATRICES.pptALLIED MATHEMATICS -I UNIT III MATRICES.ppt
ALLIED MATHEMATICS -I UNIT III MATRICES.pptssuser2e348b
 
Engg maths k notes(4)
Engg maths k notes(4)Engg maths k notes(4)
Engg maths k notes(4)Ranjay Kumar
 
Direct Methods to Solve Lineal Equations
Direct Methods to Solve Lineal EquationsDirect Methods to Solve Lineal Equations
Direct Methods to Solve Lineal EquationsLizeth Paola Barrero
 
Direct Methods to Solve Linear Equations Systems
Direct Methods to Solve Linear Equations SystemsDirect Methods to Solve Linear Equations Systems
Direct Methods to Solve Linear Equations SystemsLizeth Paola Barrero
 
Introduction To Matrix
Introduction To MatrixIntroduction To Matrix
Introduction To MatrixAnnie Koh
 

Similar to Lecture_1_matrix_operations.pdf (20)

Matrix Algebra : Mathematics for Business
Matrix Algebra : Mathematics for BusinessMatrix Algebra : Mathematics for Business
Matrix Algebra : Mathematics for Business
 
Unit 9 graph
Unit   9 graphUnit   9 graph
Unit 9 graph
 
Graphs in datastructures
Graphs in datastructuresGraphs in datastructures
Graphs in datastructures
 
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringGraph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
 
Brief review on matrix Algebra for mathematical economics
Brief review on matrix Algebra for mathematical economicsBrief review on matrix Algebra for mathematical economics
Brief review on matrix Algebra for mathematical economics
 
6. Graphs
6. Graphs6. Graphs
6. Graphs
 
Matrix
MatrixMatrix
Matrix
 
Matrices and determinants
Matrices and determinantsMatrices and determinants
Matrices and determinants
 
Mathematics fundamentals
Mathematics fundamentalsMathematics fundamentals
Mathematics fundamentals
 
Matrices and its Applications to Solve Some Methods of Systems of Linear Equa...
Matrices and its Applications to Solve Some Methods of Systems of Linear Equa...Matrices and its Applications to Solve Some Methods of Systems of Linear Equa...
Matrices and its Applications to Solve Some Methods of Systems of Linear Equa...
 
Matrices and its Applications to Solve Some Methods of Systems of Linear Equa...
Matrices and its Applications to Solve Some Methods of Systems of Linear Equa...Matrices and its Applications to Solve Some Methods of Systems of Linear Equa...
Matrices and its Applications to Solve Some Methods of Systems of Linear Equa...
 
University of duhok
University of duhokUniversity of duhok
University of duhok
 
matrix-algebra-for-engineers (1).pdf
matrix-algebra-for-engineers (1).pdfmatrix-algebra-for-engineers (1).pdf
matrix-algebra-for-engineers (1).pdf
 
ALLIED MATHEMATICS -I UNIT III MATRICES.ppt
ALLIED MATHEMATICS -I UNIT III MATRICES.pptALLIED MATHEMATICS -I UNIT III MATRICES.ppt
ALLIED MATHEMATICS -I UNIT III MATRICES.ppt
 
Engg maths k notes(4)
Engg maths k notes(4)Engg maths k notes(4)
Engg maths k notes(4)
 
Direct Methods to Solve Lineal Equations
Direct Methods to Solve Lineal EquationsDirect Methods to Solve Lineal Equations
Direct Methods to Solve Lineal Equations
 
Direct methods
Direct methodsDirect methods
Direct methods
 
Direct Methods to Solve Linear Equations Systems
Direct Methods to Solve Linear Equations SystemsDirect Methods to Solve Linear Equations Systems
Direct Methods to Solve Linear Equations Systems
 
Direct methods
Direct methodsDirect methods
Direct methods
 
Introduction To Matrix
Introduction To MatrixIntroduction To Matrix
Introduction To Matrix
 

More from AmirMohamedNabilSale (18)

LecccccccccccccProgrammingLecture-09.pdf
LecccccccccccccProgrammingLecture-09.pdfLecccccccccccccProgrammingLecture-09.pdf
LecccccccccccccProgrammingLecture-09.pdf
 
p1.pdf
p1.pdfp1.pdf
p1.pdf
 
9.b-CMPS 403-F20-Session 9-Intro to ML II.pdf
9.b-CMPS 403-F20-Session 9-Intro to ML II.pdf9.b-CMPS 403-F20-Session 9-Intro to ML II.pdf
9.b-CMPS 403-F20-Session 9-Intro to ML II.pdf
 
6.c-CMPS 403-F19-Session 6-Resolution.pdf
6.c-CMPS 403-F19-Session 6-Resolution.pdf6.c-CMPS 403-F19-Session 6-Resolution.pdf
6.c-CMPS 403-F19-Session 6-Resolution.pdf
 
3.b-CMPS 403-F20-Session 3-Solving CSP I.pdf
3.b-CMPS 403-F20-Session 3-Solving CSP I.pdf3.b-CMPS 403-F20-Session 3-Solving CSP I.pdf
3.b-CMPS 403-F20-Session 3-Solving CSP I.pdf
 
2.a-CMPS 403-F20-Session 2-Search Problems.pdf
2.a-CMPS 403-F20-Session 2-Search Problems.pdf2.a-CMPS 403-F20-Session 2-Search Problems.pdf
2.a-CMPS 403-F20-Session 2-Search Problems.pdf
 
LectureNote2.pdf
LectureNote2.pdfLectureNote2.pdf
LectureNote2.pdf
 
ML_1.pdf
ML_1.pdfML_1.pdf
ML_1.pdf
 
232021-211025052822.pdf
232021-211025052822.pdf232021-211025052822.pdf
232021-211025052822.pdf
 
9a52019-211025074532.pdf
9a52019-211025074532.pdf9a52019-211025074532.pdf
9a52019-211025074532.pdf
 
random-211016153637.pdf
random-211016153637.pdfrandom-211016153637.pdf
random-211016153637.pdf
 
Linux.pdf
Linux.pdfLinux.pdf
Linux.pdf
 
Linux_Commands.pdf
Linux_Commands.pdfLinux_Commands.pdf
Linux_Commands.pdf
 
AI in covid 19 (1).pptx
AI in covid 19 (1).pptxAI in covid 19 (1).pptx
AI in covid 19 (1).pptx
 
COVID-19 PowerPoint.pptx
COVID-19 PowerPoint.pptxCOVID-19 PowerPoint.pptx
COVID-19 PowerPoint.pptx
 
Edu week2022.pptx
Edu week2022.pptxEdu week2022.pptx
Edu week2022.pptx
 
ML_DT.pdf
ML_DT.pdfML_DT.pdf
ML_DT.pdf
 
2.pdf
2.pdf2.pdf
2.pdf
 

Recently uploaded

GENERAL PHYSICS 2 REFRACTION OF LIGHT SENIOR HIGH SCHOOL GENPHYS2.pptx
GENERAL PHYSICS 2 REFRACTION OF LIGHT SENIOR HIGH SCHOOL GENPHYS2.pptxGENERAL PHYSICS 2 REFRACTION OF LIGHT SENIOR HIGH SCHOOL GENPHYS2.pptx
GENERAL PHYSICS 2 REFRACTION OF LIGHT SENIOR HIGH SCHOOL GENPHYS2.pptxRitchAndruAgustin
 
Microteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical EngineeringMicroteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical EngineeringPrajakta Shinde
 
Radiation physics in Dental Radiology...
Radiation physics in Dental Radiology...Radiation physics in Dental Radiology...
Radiation physics in Dental Radiology...navyadasi1992
 
Pests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdfPests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdfPirithiRaju
 
Microphone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptxMicrophone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptxpriyankatabhane
 
trihybrid cross , test cross chi squares
trihybrid cross , test cross chi squarestrihybrid cross , test cross chi squares
trihybrid cross , test cross chi squaresusmanzain586
 
GenBio2 - Lesson 1 - Introduction to Genetics.pptx
GenBio2 - Lesson 1 - Introduction to Genetics.pptxGenBio2 - Lesson 1 - Introduction to Genetics.pptx
GenBio2 - Lesson 1 - Introduction to Genetics.pptxBerniceCayabyab1
 
CHROMATOGRAPHY PALLAVI RAWAT.pptx
CHROMATOGRAPHY  PALLAVI RAWAT.pptxCHROMATOGRAPHY  PALLAVI RAWAT.pptx
CHROMATOGRAPHY PALLAVI RAWAT.pptxpallavirawat456
 
OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024innovationoecd
 
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.PraveenaKalaiselvan1
 
Environmental Biotechnology Topic:- Microbial Biosensor
Environmental Biotechnology Topic:- Microbial BiosensorEnvironmental Biotechnology Topic:- Microbial Biosensor
Environmental Biotechnology Topic:- Microbial Biosensorsonawaneprad
 
Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024AyushiRastogi48
 
Harmful and Useful Microorganisms Presentation
Harmful and Useful Microorganisms PresentationHarmful and Useful Microorganisms Presentation
Harmful and Useful Microorganisms Presentationtahreemzahra82
 
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxSTOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxMurugaveni B
 
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)riyaescorts54
 
User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)Columbia Weather Systems
 
GenAI talk for Young at Wageningen University & Research (WUR) March 2024
GenAI talk for Young at Wageningen University & Research (WUR) March 2024GenAI talk for Young at Wageningen University & Research (WUR) March 2024
GenAI talk for Young at Wageningen University & Research (WUR) March 2024Jene van der Heide
 
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptx
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptxTHE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptx
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptxNandakishor Bhaurao Deshmukh
 
Base editing, prime editing, Cas13 & RNA editing and organelle base editing
Base editing, prime editing, Cas13 & RNA editing and organelle base editingBase editing, prime editing, Cas13 & RNA editing and organelle base editing
Base editing, prime editing, Cas13 & RNA editing and organelle base editingNetHelix
 

Recently uploaded (20)

GENERAL PHYSICS 2 REFRACTION OF LIGHT SENIOR HIGH SCHOOL GENPHYS2.pptx
GENERAL PHYSICS 2 REFRACTION OF LIGHT SENIOR HIGH SCHOOL GENPHYS2.pptxGENERAL PHYSICS 2 REFRACTION OF LIGHT SENIOR HIGH SCHOOL GENPHYS2.pptx
GENERAL PHYSICS 2 REFRACTION OF LIGHT SENIOR HIGH SCHOOL GENPHYS2.pptx
 
Microteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical EngineeringMicroteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical Engineering
 
Let’s Say Someone Did Drop the Bomb. Then What?
Let’s Say Someone Did Drop the Bomb. Then What?Let’s Say Someone Did Drop the Bomb. Then What?
Let’s Say Someone Did Drop the Bomb. Then What?
 
Radiation physics in Dental Radiology...
Radiation physics in Dental Radiology...Radiation physics in Dental Radiology...
Radiation physics in Dental Radiology...
 
Pests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdfPests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdf
 
Microphone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptxMicrophone- characteristics,carbon microphone, dynamic microphone.pptx
Microphone- characteristics,carbon microphone, dynamic microphone.pptx
 
trihybrid cross , test cross chi squares
trihybrid cross , test cross chi squarestrihybrid cross , test cross chi squares
trihybrid cross , test cross chi squares
 
GenBio2 - Lesson 1 - Introduction to Genetics.pptx
GenBio2 - Lesson 1 - Introduction to Genetics.pptxGenBio2 - Lesson 1 - Introduction to Genetics.pptx
GenBio2 - Lesson 1 - Introduction to Genetics.pptx
 
CHROMATOGRAPHY PALLAVI RAWAT.pptx
CHROMATOGRAPHY  PALLAVI RAWAT.pptxCHROMATOGRAPHY  PALLAVI RAWAT.pptx
CHROMATOGRAPHY PALLAVI RAWAT.pptx
 
OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024
 
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
BIOETHICS IN RECOMBINANT DNA TECHNOLOGY.
 
Environmental Biotechnology Topic:- Microbial Biosensor
Environmental Biotechnology Topic:- Microbial BiosensorEnvironmental Biotechnology Topic:- Microbial Biosensor
Environmental Biotechnology Topic:- Microbial Biosensor
 
Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024Vision and reflection on Mining Software Repositories research in 2024
Vision and reflection on Mining Software Repositories research in 2024
 
Harmful and Useful Microorganisms Presentation
Harmful and Useful Microorganisms PresentationHarmful and Useful Microorganisms Presentation
Harmful and Useful Microorganisms Presentation
 
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxSTOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
 
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)
 
User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)
 
GenAI talk for Young at Wageningen University & Research (WUR) March 2024
GenAI talk for Young at Wageningen University & Research (WUR) March 2024GenAI talk for Young at Wageningen University & Research (WUR) March 2024
GenAI talk for Young at Wageningen University & Research (WUR) March 2024
 
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptx
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptxTHE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptx
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptx
 
Base editing, prime editing, Cas13 & RNA editing and organelle base editing
Base editing, prime editing, Cas13 & RNA editing and organelle base editingBase editing, prime editing, Cas13 & RNA editing and organelle base editing
Base editing, prime editing, Cas13 & RNA editing and organelle base editing
 

Lecture_1_matrix_operations.pdf

  • 1. 88 Matrix Operations ▷ 1 ▷ Computational Problem Solving
  • 2. 88 A matrix (plural: matrices) is simply an ‘array’ of numbers, e.g. But the power of matrices comes from being able to multiply matrices by vectors and matrices by matrices and ‘invert’ them: we can: 1. represent linear transformations using matrices (e.g. rotations, reflections and enlargements) 2. Use them to solve linear simultaneous equations. The first of these means matrices are particularly useful in 3D graphics/animation, since they allow us to rotate the camera and project 3D data onto a 2D viewing plane. But matrices are used everywhere, including robotics, computer vision, optimisation, classical and quantum mechanics, electromagnetism, optics, graph theory, statistics, ... On a simple level, a matrix is simply a way to organise values into rows and columns, and represent these multiple values as a single structure. ▷ 2 ▷ Introduction to matrices
  • 3. 88 The zero matrix, 𝑍 or 𝟎 is the matrix with zero as each element. The identity matrix is the matrix with ones on its main diagonal. The 2x2 identity matrix is 𝐼 = 1 0 0 1 And has the property that 𝐼𝐴 = 𝐴𝐼 = 𝐴 In general, matrix multiplication is not commutative, i.e. 𝐴𝐵 ≠ 𝐵𝐴 It is, however, associative, i.e. 𝐴 𝐵𝐶 = 𝐴𝐵 𝐶 ▷ 3 ▷ Introduction to matrices
  • 4. 88 The dimension of a matrix is its size, in terms of its number of rows and columns. 2  3 3  1 1  3 A matrix can have square or curvy brackets*. Matrix Column Vector (The vector you know and love) Row Vector So a matrix with one column is simply a vector in the usual sense. ▷ 4 ▷ Introduction to matrices
  • 5. 88 If we wish a variable to represent a matrix, we use bold, capital letters. 𝑨 = 1 6 −3 𝑪 = 𝑷−𝟏𝑻𝑷 Each value within a matrix is known as an element. If A is a matrix, then we can refer to the element in the ith row and jth column as 𝑎𝑖,𝑗. 𝑐1,2 = 3 𝑐2,1 = 4 𝑐1,3 = −7 ▷ 5 ▷ Introduction to matrices
  • 6. 88 Simply add/subtract the corresponding elements of each matrix. They must be of the same dimension. ▷ 6 ▷ Adding/Subtracting Matrices
  • 7. 88 ▷ 7 ▷ Vectors A row vector is a 1 × 𝑛 matrix and a column vector is a 𝑛 × 1 vector. Vectors have similar properties to matrices (in terms of addition and subtraction) although have their own form of multiplication. There are two ways to multiply vectors – dot product and cross product. We only look at dot product which is (for a 3D vector) 𝑎 𝑏 𝑐 ⋅ 𝑥 𝑦 𝑧 = 𝑎𝑥 + 𝑏𝑦 + 𝑐𝑧 For example: 1 4 ⋅ 2 −1 = 1 × 2 + 4 × −1 = 2 − 4 = −2
  • 8. 88 A scalar is a number which can ‘scale’ the elements inside a matrix/vector. 1 2 3 ▷ 8 ▷ Scalar Multiplication
  • 9. 88 This is where things get slightly more complicated... 1 0 3 -2 2 8 4 3 7 -1 0 2 5 1 1 7 0 3 8 -3 -11 We start with this row and column, and sum the products of each pair. (1 x 5) + (0 x 1) + (3 x 0) + (-2 x 8) = -11 This is known as finding the “dot/scalar product” of the two vectors. 16 Now repeat for the next row of the left matrix... 42 61 50 -6 ▷ 9 ▷ Matrix Multiplication
  • 10. 88 = 1 2 3 1 2 3 = 14 1 2 3 1 2 3 = 1 2 3 2 4 6 3 6 9 a b c d e f ▷ 10 ▷ Matrix Multiplication
  • 11. 88 Matrix multiplications are not always valid: the dimensions have to agree. Note that only square matrices (i.e. same width as height) can be raised to a power. Dimensions of A Dimension of B Dimensions of AB (if valid) 2  3 3  4 2  4 1  3 2  3 Not valid. 6  2 2  4 6  4 1  3 3  1 1  1 7  5 7  5 Not valid. 10  10 10  9 10  9 3  3 3  3 3  3 ▷ 11 ▷ Matrix Multiplication
  • 12. 88 The transpose of a matrix is formed by swapping the columns and row. For example, if 𝐴 = 𝑎 𝑏 𝑐 𝑑 , then 𝐴𝑇 = 𝑎 𝑐 𝑏 𝑑 The determinant of a 2x2 matrix is 𝑎𝑑 − 𝑏𝑐, written as det 𝐴 = 𝑎𝑑 − 𝑏𝑐. The inverse is: 𝐴−1 = 1 𝑎𝑑 − 𝑏𝑐 𝑑 −𝑏 −𝑐 𝑎 We can use this to solve simultaneous equations i.e. 𝑎𝑥 + 𝑏𝑦 = 𝑒 𝑐𝑥 + 𝑑𝑦 = 𝑓 Becomes 𝐴𝑥 = 𝑏 or 𝑎 𝑏 𝑐 𝑑 𝑥 𝑦 = 𝑒 𝑓 Which means that: 𝑥 = 𝐴−1 𝑏, or 𝑥 𝑦 = 𝑎 𝑏 𝑐 𝑑 −1 𝑒 𝑓 ▷ 12 ▷ Matrix transpose / Inverse
  • 13. 88 13
  • 14. 88 Graphs and Trees ▷ 14 ▷ Computational Problem Solving
  • 15. 88 ▷ 15 ▷ Applications Graph theory is important to find: a) Shortest distance between two points b) Search engine optimisation c) Communications d) Travelling salesperson problem e) Graph colouring (used for parallel computing) f) Data science
  • 16. 88 ▷ 16 ▷ Introduction Graph theory is not about the sort of graphs you did at school!
  • 17. 88 ▷ 17 ▷ Applications
  • 18. 88 ▷ 18 ▷ What is a graph? 1. A graph is a set of vertices (V) and edges (E) 2. Each edge in E has two endpoints which connect two elements of V (Possibly the same element) 3. In an undirected graph, edges have no specific direction, and can be considered to connect a to b or b to a 4. In a directed graph, edges do have a specific direction 5. The number of endpoints at a vertex is called the degree of that vertex
  • 19. 88 ▷ 19 ▷ Representing Graphs We can represent a graph with a diagram. The vertices are blobs Undirected edges are lines a b c e d g f
  • 20. 88 ▷ 20 ▷ Representing Graphs We can represent a graph with a diagram. The vertices are blobs Undirected edges are lines Directed edges are arrows a b c e d g f
  • 21. 88 Definition ▷ 21 ▷ Terminology The degree of a vertex in an undirected graph is the number of edges incident to it, except that a loop contributes twice to the degree. The degree of a vertex 𝑣 is denoted by deg(𝑣) deg 𝑎 = 2 deg 𝑏 = 4 deg 𝑔 = 0 For any graph 𝐺 the sum of the degrees for all vertices equals to the number of edges multiplied by two. That is, 2𝑚 = σ𝑣∈𝑉 deg(𝑣) where 𝑚 is the number of edges in the graph 𝐺 = (𝑉, 𝐸)
  • 22. 88 My Turn Your Turn ▷ 22 ▷ Degrees of Vertices Example Find the number of vertices, the number of edges and the degree of each vertex in the given undirected graph. Identify all isolated and pendant vertices. 𝑣 = 6 𝑒 = 6 deg 𝑎 = 2 deg 𝑏 = 4 deg 𝑐 = 1 deg 𝑑 = 0 deg 𝑒 = 2 deg 𝑓 = 3 𝑐 is pendant (vertex has degree 1) and 𝑑 is isolated (vertex has degree 0). Find the number of vertices, the number of edges and the degree of each vertex in the given undirected graph. Identify all isolated and pendant vertices. 𝑣 = 5 𝑒 = 12 deg 𝑎 = 5 deg 𝑏 = 6 deg 𝑐 = 5 deg 𝑑 = 5 deg 𝑒 = 3 There are no isolated or pendent vertices as none of the vertices have degree 0 or 1
  • 23. 88 ▷ 23 ▷ Handshaking Lemma Every edge has two endpoints The sum of all the endpoints in a graph must be even. If there are n edges, there must be 2𝑛 endpoints This is known as the "Handshaking Theorem" The sum of all the endpoints in a graph is equal to the sum of all the vertex degrees The sum of all vertex degrees must be even ෍ 𝑣∈𝑉 deg 𝑣 = 2|𝐸| ෍ 𝑣∈𝑉 deg 𝑣 = deg 1 + deg 2 + deg 3 + deg 4 + deg 5 + deg(6) = 2 + 3 + 2 + 3 + 3 + 1 = 14 2 𝐸 = 2 × 7 = 14 (7 edges in the graph)
  • 24. 88 Definition ▷ 24 ▷ Definition of Graph Using Sets We can represent graphs with sets G = (V, E) V = set of vertices, e.g {a,b,c,d,e} E = set of edges • e.g. Undirected: E = { {a,b}, {b,c}, {d,e} } • e.g. Directed: E = { (a,b), (b,c), (d,e) }
  • 25. 88 Definition ▷ 25 ▷ Simple graphs A graph in which each edge connects two different vertices and where no two edges connect the same pair of vertices is called a simple graph A simple graph: And not simple: What makes the simple graph different to a non-simple graph?
  • 26. 88 Definition ▷ 26 ▷ Simple Graph Simple Graph • Simple graphs are UNDIRECTED • Edges connect two different vertices • So no loops on vertices • Maximum of one edge between any pair of vertices Simple Directed Graph • Same – but edges are directed NOTE: To avoid confusion this module will standardise on the common definition of a simple graph as UNDIRECTED (as found in Rosen)
  • 27. 88 Definition Characteristics Examples Non-Examples ▷ 27 ▷ Frayer Diagram Simple Graph a simple graph is an unweighted, undirected graph containing no loops or multiple edges. It can be either connected or disconnected
  • 28. 88 • An undirected graph is connected if there is at least one path between any two vertices • A directed graph is strongly connected if there is at least one path between any two vertices that follows all the directions of the edges • A directed graph is weakly connected is there is at least one path between any two vertices that ignores all the directions of the edges
  • 29. 88 • A bridge is an edge which, if removed, would cause the graph to become disconnected a c b d f e
  • 30. 88 • A graph that is not connected has two or more connected components. • These components are disjoint • The union of all components is the original graph a c b d f e
  • 31. 88 Definition ▷ 31 ▷ Adjacency List A table with 1 row per vertex, listing its adjacent vertices. a b d c f e Vertex Adjacent Vertices a b b, c a, c, e, f c a, b, f d e b f c, b
  • 32. 88 Definition ▷ 32 ▷ Adjacency Matrix A way to represent simple graphs • possibly with self-loops. Matrix A=[aij], where aij is 1 if {vi, vj} is an edge of G, and is 0 otherwise. Can extend to pseudographs by letting each matrix elements be the number of links (possibly >1) between the nodes.
  • 33. 88 Examples ▷ 33 ▷ Adjacency Matrix – Undirected 0 1 7 2 5 3 4 6
  • 34. 88 Examples ▷ 34 ▷ Adjacency Matrix – Directed 1 2 3 4
  • 35. 88 My Turn Your Turn ▷ 35 ▷ Adjacency Matrix Example 0 0 1 0 0 0 6 0 0 1 0 1 1 5 1 1 0 1 0 0 4 0 0 1 0 1 0 3 0 1 0 1 0 1 2 0 1 0 0 1 0 1 6 5 4 3 2 1 0 2 0 1 1 5 2 0 0 1 1 4 0 0 0 0 0 3 1 1 0 0 2 2 1 1 0 2 0 1 5 4 3 2 1 1 2 3 4 5
  • 36. 88 ▷ 36 ▷ Graph representation Adjacency matrices: Incidence matrices: 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 𝑎 𝑏 𝑐 𝑑 𝑎 𝑏 𝑐 𝑑
  • 37. 88 • The complete graph Kn • For any nN, a complete graph on n vertices, Kn, is a simple graph with n nodes in which every node is adjacent to every other node: u,vV: uv{u,v}E. • A set of n vertices – all connected to each other K1 K2 K3 K4 K5 K6 Note that Kn has edges. 2 ) 1 ( 1 1 − =  − = n n i n i
  • 38. 88 • The cycle graph Cn • A set of n vertices (n ≥3) { c1, c2, c3, … , cn } • A set of edges { {c1,c2}, {c2,c3}, {c3, c4}, …, {cn-1, cn} } C3 C4 C5 C6 C7 C8 How many edges are there in Cn?
  • 39. 88 • The wheel graph Wn • A set of n+1 vertices (n ≥4) { v, c1, c2, c3, … , cn } • A set of edges { {c1,c2}, {c2,c3}, {c3, c4}, …, {cn-1, cn} } ∪ { {v,c1}, {v,c2}, {v,c3}, …, {v, cn} } • For any n3, a wheel Wn, is a simple graph obtained by taking the cycle Cn and adding one extra vertex vhub and n extra edges {{vhub,v1}, {vhub,v2},…,{vhub,vn}}. W3 W4 W5 W6 W7 W8 How many edges are there in Wn?
  • 40. 88 • The n-cube Qn • A set of 2n vertices • Each vertex represents a bit string • A set of edges • Each edge connects two vertices that differ by one bit Q0 Q1 Q2 Q3 Q4 Number of vertices: 2n. Number of edges:Exercise to try!
  • 41. 88 • To draw the n-cube Qn • Start with Q1 • Duplicate it • Prefix the original vertices with "0" • Prefix the duplicate vertices with "1" • Connect the corresponding vertices 00 01 10 11
  • 42. 88 • To draw the n-cube Qn • Start with Q2 • Duplicate it • Prefix the original vertices with "0" • Prefix the duplicate vertices with "1" • Connect the corresponding vertices 000 001 010 011 100 101 110 111
  • 43. 88 • A graph is bipartite if its vertices can be divided into two subsets, so that every edge connects a vertex in one subset to a vertex in the other. • Here the subsets are {a,b,c} and {d,e} a b c d e
  • 44. 88 • A graph is bipartite if its vertices can be divided into two subsets, so that every edge connects a vertex in one subset to a vertex in the other. • Here the subsets are {a,b,c} and {d,e} a b c d e
  • 45. 88 • A bipartite graph is complete if every edge in one subset is connected to every edge in the other • The complete bipartite graph of m vertices in one subset and n vertices in the other is denoted Km,n a b c d e This is the complete bipartite graph K3,2 K4,3 Km,n has _____ nodes and _____ edges.
  • 46. 88 • Diagrams can be drawn anyhow • Vertices can go anywhere • Lines can cross (and in some cases, must cross) • With practice, you'll discover how to improve neatness.
  • 47. 88 ▷ 47 ▷ Special simple graphs A complete graph on 𝑛 vertices 𝐾𝑛 A cycle 𝐶𝑛 𝑛 ≥ 3 A wheel 𝑊 𝑛
  • 48. 88 ▷ 48 ▷ Bipartite graphs A simple graph 𝐺 is called bipartite if its vertex set 𝑉 can be partitioned into two disjoint sets 𝑉1 and 𝑉2 such that every edge in the graph connects a vertex in 𝑉1 and a vertex in 𝑉2 𝐾𝑚,𝑛: a complete bipartite graph with 𝑉1 = 𝑚 and 𝑉2 = 𝑛
  • 49. 88 ▷ 49 ▷ Graph isomorphism Informally (you will see a formal definition of graph isomorphism later during the course): There is a useful terminology for graphs with the same structure
  • 50. 88 ▷ 50 ▷ Graph isomorphism Which graphs are isomorphic?
  • 51. 88 Classification Simple ? Connected ? Directed ? Multigraph ? Kn ? Cn ? Bipartite ? Km,n ? Classification Simple ✓ Connected ✓ Directed  Multigraph  Kn ✓ K3 Cn ✓ C3 Bipartite  Km,n  a c b
  • 52. 88 Classification Simple ? Connected ? Directed ? Multigraph ? Kn ? Cn ? Bipartite ? Km,n ? Classification Simple  Connected ✓Strong Directed ✓ Multigraph  Kn  Cn  Bipartite  Km,n  a b NOTE: To avoid confusion this module will standardise on the common definition of a simple graph as UNDIRECTED (as found in Rosen)
  • 53. 88 Classification Simple ? Connected ? Directed ? Multigraph ? Kn ? Cn ? Bipartite ? Km,n ? Classification Simple ? Connected ? Directed ? Multigraph ? Kn ? Cn ? Bipartite ? Km,n ? Classification Simple  Connected  Directed  Multigraph  Kn  Cn  Bipartite  Km,n  a c b
  • 54. 88 Classification Simple ? Connected ? Directed ? Multigraph ? Kn ? Cn ? Bipartite ? Km,n ? Classification Simple  Connected ✓ Weak Directed ✓ Multigraph  Kn  Cn  Bipartite  Km,n  a b c d e
  • 55. 88 Classification Simple ? Connected ? Directed ? Multigraph ? Kn ? Cn ? Bipartite ? Km,n ? Classification Simple ✓ Connected  Directed  Multigraph  Kn  Cn  Bipartite  Km,n  a c b
  • 56. 88 Classification Simple ? Connected ? Directed ? Multigraph ? Kn ? Cn ? Bipartite ? Km,n ? Classification Simple ✓ Connected ✓ Directed  Multigraph  Kn  Cn  Bipartite ✓ Km,n ✓K2,4 a c d e f b
  • 57. 88 Classification Simple ? Connected ? Directed ? Multigraph ? Kn ? Cn ? Bipartite ? Km,n ? Classification Simple ✓ Connected ✓ Directed  Multigraph  Kn  Cn ✓ C4 Bipartite ✓ Km,n ✓ K2,2 a c b d
  • 58. 88 Classification Simple ? Connected ? Directed ? Multigraph ? Kn ? Cn ? Bipartite ? Km,n ? Classification Simple ✓ Connected ✓ Directed  Multigraph  Kn  Cn ✓ C4 Bipartite ✓ Km,n ✓ K2,2 a c b d