Professional Documents
Culture Documents
MATH1800 LEC7 Blackboard
MATH1800 LEC7 Blackboard
School of Mathematical and Physical Sciences, Faculty of Science and Information Technology, University of Newcastle, Australia
Semester 2
Lec 7
Network Models
A Network is an interconnected system of objects.
For example,
Social network (facebook, myspace, linkedin, etc.) Communication network (internet, mobile network, wireless network, etc) Neural networks Electricity network Transportation network Supply chain network
Lec 7
Network Models
www.smartgridaustralia.com.au www.climatechange.gov.au
Lec 7
Network Models
Lec 7
Network Models
Biology
Lec 7
Network Models
Communication networks
Lec 7
Network Models
Network models can help with:
Efficient routing (multi modal) Identifying flow capacity/bottlenecks Analysing connectivity Decision making regarding Infrastructure investment
Transportation networks
Lec 7
Network Models
Social networks
Lec 7
Network Models
A Network is an interconnected system of objects.
For example,
Social network (facebook, myspace, linkedin, etc.) Communication network (internet, mobile network, wireless network, etc) Neural networks Electricity network Transportation network Supply chain network
Lec 7
Network Models
A Network is an interconnected system of objects.
For example,
Social network (facebook, myspace, linkedin, etc.) Communication network (internet, mobile network, wireless network, etc) Neural networks Electricity network Transportation network Supply chain network
Intuitive, natural paradigm for thinking about many real problems Special properties Extremely fast and efficient algorithms/techniques available Large scale problems can be solved We will look at:
Spanning trees Shortest paths Network Flows Maximum Flow Minimum Cost Flow (time permitting)
Lec 7
2 1 3 4 7 8 5
6 9 10
Lec 7
{i, j}
Undirected edge Unordered node pair
Graph = (N, A)
Lec 7
Graph
6 9
(i, j)
Directed edge Ordered node pair
{i, j}
Undirected edge Unordered node pair
Graph = (N, A)
Lec 7
Graph
6 9
Lec 7
Graph
6 9
Q. What are some other types of information that could be useful in network modelling? Arc costs: cij is the cost associated with arc (i,j) or edge {i,j} Arc/node capacities
Lec 7
Graph
6 9
Q. What are some interesting components of a graph/digraph? Path: sequence of nodes connected by edges/arcs Directed and undirected paths in digraphs
Cycle: path that starts and ends at the same node Directed and undirected cycles in digraphs
Lec 7
Graph
6 9
Directed path N = {1,2,3,,10} A = {(1,3), (2,1), (3,2), (3,8), (4,2), (4,3), (4,5), } N = {1,2,3,,10}
Undirected path
Lec 7
Graph
6 9
Directed path N = {1,2,3,,10} A = {(1,3), (2,1), (3,2), (3,8), (4,2), (4,3), (4,5), } N = {1,2,3,,10}
Undirected path
Lec 7
Graph
6 9
Undirected path N = {1,2,3,,10} A = {(1,3), (2,1), (3,2), (3,8), (4,2), (4,3), (4,5), } N = {1,2,3,,10}
Undirected path
Lec 7
Graph
6 9
Directed cycle N = {1,2,3,,10} A = {(1,3), (2,1), (3,2), (3,8), (4,2), (4,3), (4,5), } N = {1,2,3,,10}
Undirected cycle
10
Lec 7
Graph
6 9
Directed cycle N = {1,2,3,,10} A = {(1,3), (2,1), (3,2), (3,8), (4,2), (4,3), (4,5), } N = {1,2,3,,10}
Undirected cycle
Lec 7
Graph
6 9
Undirected cycle N = {1,2,3,,10} A = {(1,3), (2,1), (3,2), (3,8), (4,2), (4,3), (4,5), } N = {1,2,3,,10}
Undirected cycle
11
Lec 7
Graph
6 9
Q. What are some interesting characteristics of a graph/digraph? Acyclic: does not contain any (directed) cycles
Lec 7
Graph
6 9
Acyclic
Acyclic
2 1 3 4 7 8 5
6 9 10 1
2 4 3 7 8 5
6 9 10
Cyclic
Cyclic
12
Lec 7
Graph
6 9
Q. What are some interesting characteristics of a graph/digraph? Acyclic: does not contain any (directed) cycles Connected: there is a path from each node to every other node A directed path from each node to every other node in digraph: Strongly connected An undirected path from each node to every other node in digraph : Weakly connected
Lec 7
Graph
6 9
Weakly connected
Disconnected
2 1 3 4 7 8 5
6 9 10 1
2 4 3 7 8 5
6 9 10
Strongly connected
Connected
13
Lec 7
Tree
Tree
An undirected graph is a Tree if it is connected and acyclic
Lec 7
Examples of Trees:
2 1 3 4 7 8 5 10 Tree 6 9 2 3 Tree 8 1 4 5 6 2 1 7 6 Tree 3 4 2 5 1 3 7 8 Tree 4 5 6
Tree
An undirected graph is a Tree if it is connected and acyclic
14
Lec 7
Examples of Trees:
2 1 3 4 7 8 5 10 Tree 6 9 2 3 Tree 8 1 4 5 6 2 1 7 6 Tree 3 4 2 5 1 3 7 8 Tree 4 5 6
Tree
An undirected graph is a Tree if it is connected and acyclic
Lec 7
Examples of Trees:
2 1 3 4 7 8 10 nodes 9 edges 5 10 Tree 6 nodes 5 edges 6 9 2 3 Tree 1 4 5 6 2 1 6 8 7 Tree 8 nodes 7 edges 3 4 2 5 1 3 7 8 Tree 8 nodes 7 edges 4 5 6
Tree
An undirected graph is a Tree if it is connected and acyclic Q. Is it true that a tree with n nodes will have n-1 edges? A. Yes. (Why? Try drawing a tree with 4 nodes and 4 edges, 5 nodes and 5 edges, etc.
you will always get a cycle)
15
Lec 7
Examples of Trees:
2 1 3 4 7 8 10 nodes 9 edges 5 10 Tree 6 nodes 5 edges 6 9 2 3 Tree 1 4 5 6 2 1 8 7 Tree 8 nodes 7 edges 6 3 4 2 5 1 3 7 8 Tree 8 nodes 7 edges 4 5 6
Tree
An undirected graph is a Tree if it is connected and acyclic Q. Is it true that a tree with n nodes will have n-1 edges? A. Yes. (Why? Try drawing a tree with 4 nodes and 4 edges, 5 nodes and 5 edges, etc.
you will always get a cycle)
Lec 7
Examples of Trees:
2 1 3 4 7 8 10 nodes 9 edges 5 10 Tree 6 nodes 5 edges 6 9 2 3 Tree 1 4 5 6 2 1 6 8 7 Tree 8 nodes 7 edges 3 4 2 5 1 3 7 8 Tree 8 nodes 7 edges 4 5 6
Tree
An undirected graph is a Tree if it is connected and acyclic Q. Is it true that a tree with n nodes will have n-1 edges? A. Yes. (Why? Try drawing a tree with 4 nodes and 4 edges, 5 nodes and 5 edges, etc.
you will always get a cycle)
Q. Is it true that a graph with n nodes and n-1 edges is a tree? A. No.
1 2 3 4
Q. Is it true that a connected graph with n nodes and n-1 edges is a tree?
16
Lec 7
Examples of Trees:
2 1 3 4 7 8 10 nodes 9 edges 5 10 Tree 6 nodes 5 edges 6 9 2 3 Tree 1 4 5 6 2 1 8 7 Tree 8 nodes 7 edges 6 3 4 2 5 1 3 7 8 Tree 8 nodes 7 edges 4 5 6
Tree
An undirected graph is a Tree if it is connected and acyclic Q. Is it true that a tree with n nodes will have n-1 edges? A. Yes. (Why? Try drawing a tree with 4 nodes and 4 edges, 5 nodes and 5 edges, etc.
you will always get a cycle)
Q. Is it true that a graph with n nodes and n-1 edges is a tree? A. No.
1 2 3 4
Q. Is it true that a connected graph with n nodes and n-1 edges is a tree? A. Yes.
Lec 7
Subgraph
6 9
Spanning Tree
Tree
An undirected graph is a Tree if it is connected and acyclic
Spanning Tree
Some subset of nodes and arcs
A subgraph is a Spanning Tree if it is a tree that contains every node of the graph.
17
Lec 7
2 1 3 4 7 5
6 9 10 Subgraph 1 1
2 4 3 7 8 5
6 9 10 Subgraph 2 1
2 4 3 7 8 5
6 9 10 Subgraph 3
Spanning Tree
A subgraph is a Spanning Tree if it is a tree that contains every node of the graph.
Lec 7
2 1 3 4 7 8 5
6 9 10 1
2 4 3 7 8 5
6 9 10
Spanning Tree
Tree
An undirected graph is a Tree if it is connected and acyclic
Spanning Tree
A subgraph is a Spanning Tree if it is a tree that contains every node of the graph.
18
Lec 7
1 3 3
4
2
edge cost
1 2 3
4 2
1 3
4 2
1 3
4 2
1 3
Cost = 8
Cost = 10
Cost = 8
Cost = 9
1 2 3
4 2
1 3
4 2
1 3
4 2
1 3
Cost = 7
Cost = 8
Cost = 6
Cost = 6
Lec 7
Nodes correspond to communication hubs Edges correspond to data links The cost of an edge corresponds to the cost associated with building that link
MST solution (why does a spanning tree give the optimal solution?)
19
Lec 7
Nodes represent patients Distance between nodes represents the similarities in symptoms
Lec 7
Nodes represent patients Distance between nodes represents the similarities in symptoms
20
Lec 7
Nodes represent patients Distance between nodes represents the similarities in symptoms
Longest edge
Lec 7
Nodes represent patients Distance between nodes represents the similarities in symptoms
Longest edge
Cluster 1
21
Lec 7
Cluster 1
Lec 7
Nodes represent patients Distance between nodes represents the similarities in symptoms
Cluster 4
Cluster 1
22
Lec 7
Yahoo uses similar techniques to find latent structures within large complex data networks
Lec 7
23
Lec 7
R1 = a b c d e R2 = a f g d e e R3 = g b c f
R4 = a h c d e
Instead of storing 5x4=20 pieces of data. We store one record and the differences to other records.
Lec 7
2 2 2
R2 R3
R1 = a b c d e R2 = a f g d e e R3 = g b c f
R4 = a h c d e
Note: A spanning tree tells us which differences to store. Hence we want MST
24
Lec 7
R1
R4
2 2
R2 R3
R1 = a b c d e R2 = a f g d e e R3 = g b c f
R4 = a h c d e
Note: A spanning tree tells us which differences to store. Hence we want MST
Lec 7
R1
R4
2 2
R2 R3
R1 = a b c d e R2 = a f g d e e R3 = g b c f
R4 = a h c d e
Note: A spanning tree tells us which differences to store. Hence we want MST
25
Lec 7
2 2
R2 R3
R1 = a b c d e R2 = a f g d e e R3 = g b c f
R4 = a h c d e
Note: A spanning tree tells us which differences to store. Hence we want MST
Lec 7
4.
26
Lec 7
2
2 3
3 5
5
7
1
5
7
2
3
3 2
6
6
Connected nodes Unconnected nodes Edges part of spanning tree Edges connecting connected nodes to unconnected nodes Edges connecting unconnected nodes Edges not part of spanning tree
Lec 7
2
2 3
3 5
5
7
Itera tion
Connected nodes 1
Unconnected nodes 2, 3, 4, 5, 6, 7, 8
1
5
7
2
3
3 2
6
6
Connected nodes Unconnected nodes Edges part of spanning tree Edges connecting connected nodes to unconnected nodes Edges connecting unconnected nodes Edges not part of spanning tree
27
Lec 7
2
2 3
3 5
5
7
Itera tion
Connected nodes 1 1, 3
Unconnected nodes 2, 3, 4, 5, 6, 7, 8 2, 4, 5, 6, 7, 8
1
5
7
2
3
3 2
6
6
Connected nodes Unconnected nodes Edges part of spanning tree Edges connecting connected nodes to unconnected nodes Edges connecting unconnected nodes Edges not part of spanning tree
Lec 7
2
2 3
3 5
5
7
Itera tion
Connected nodes 1 1, 3 1, 3, 4
Unconnected nodes 2, 3, 4, 5, 6, 7, 8 2, 4, 5, 6, 7, 8 2, 5, 6, 7, 8
1
5
7
2
2 3
3
3 2
6
6
Connected nodes Unconnected nodes Edges part of spanning tree Edges connecting connected nodes to unconnected nodes Edges connecting unconnected nodes Edges not part of spanning tree
28
Lec 7
2
2 3
3 5
5
7
Itera tion
Connected nodes 1 1, 3 1, 3, 4 1, 3, 4, 2
Unconnected nodes 2, 3, 4, 5, 6, 7, 8 2, 4, 5, 6, 7, 8 2, 5, 6, 7, 8 5, 6, 7, 8
1
5
7
2
2 3 4
3
3 2
6
6
Connected nodes Unconnected nodes Edges part of spanning tree Edges connecting connected nodes to unconnected nodes Edges connecting unconnected nodes Edges not part of spanning tree
Lec 7
2
2 3
3 5
5
7
Itera tion
Connected nodes 1 1, 3 1, 3, 4 1, 3, 4, 2 1, 3, 4, 2, 5
Unconnected nodes 2, 3, 4, 5, 6, 7, 8 2, 4, 5, 6, 7, 8 2, 5, 6, 7, 8 5, 6, 7, 8 6, 7, 8
1
5
7
2
2 3 4 5
3
3 2
6
6
Connected nodes Unconnected nodes Edges part of spanning tree Edges connecting connected nodes to unconnected nodes Edges connecting unconnected nodes Edges not part of spanning tree
29
Lec 7
2
2 3
3 5
5
7
Itera tion
Connected nodes 1 1, 3 1, 3, 4 1, 3, 4, 2 1, 3, 4, 2, 5 1, 3, 4, 2, 5, 6
Unconnected nodes 2, 3, 4, 5, 6, 7, 8 2, 4, 5, 6, 7, 8 2, 5, 6, 7, 8 5, 6, 7, 8 6, 7, 8 7, 8
1
5
7
2
2 3 4 5
3
3 2
6
6
Connected nodes Unconnected nodes Edges part of spanning tree Edges connecting connected nodes to unconnected nodes Edges connecting unconnected nodes Edges not part of spanning tree
Lec 7
2
2 3
3 5
5
7
Itera tion
Connected nodes 1 1, 3 1, 3, 4 1, 3, 4, 2 1, 3, 4, 2, 5 1, 3, 4, 2, 5, 6 1, 3, 4, 2, 5, 6, 8
Unconnected nodes 2, 3, 4, 5, 6, 7, 8 2, 4, 5, 6, 7, 8 2, 5, 6, 7, 8 5, 6, 7, 8 6, 7, 8 7, 8 7
1
5
7
2
2 3 4 5
3
3 2
6
6
6 7
Connected nodes Unconnected nodes Edges part of spanning tree Edges connecting connected nodes to unconnected nodes Edges connecting unconnected nodes Edges not part of spanning tree
30
Lec 7
2
2 3
3 5
5
7
Itera tion
Connected nodes 1 1, 3 1, 3, 4 1, 3, 4, 2 1, 3, 4, 2, 5 1, 3, 4, 2, 5, 6 1, 3, 4, 2, 5, 6, 8 1, 3, 4, 2, 5, 6, 8, 7
Unconnected nodes 2, 3, 4, 5, 6, 7, 8 2, 4, 5, 6, 7, 8 2, 5, 6, 7, 8 5, 6, 7, 8 6, 7, 8 7, 8 7
1
5
7
2
2 3 4 5
3
3 2
6
6
6 7 8
Connected nodes Unconnected nodes Edges part of spanning tree Edges connecting connected nodes to unconnected nodes Edges connecting unconnected nodes Edges not part of spanning tree
Lec 7
2
2 3
3 5
5
7
MST has edges: {1,3}, {3,4}, {3,2}, {3,6}, {2,5}, {6,8}, and {8,7}, and cost 16
1
5
7
2
3
3 2
6
6
Connected nodes Unconnected nodes Edges part of spanning tree Edges connecting connected nodes to unconnected nodes Edges connecting unconnected nodes Edges not part of spanning tree
31
Lec 7
4.
Q. Will this algorithm always construct a spanning tree? A. Yes. After choosing initial node in step 1, in each subsequent step we add one additional node and edge until all nodes are selected. Hence we have n nodes, and n-1 edges selected. Furthermore, the construction always connects an unconnected node to a connected node so the subgraph will also be connected. n nodes + n-1 edges + connected subgraph Spanning Tree.
Lec 7
4.
Q. Will this algorithm always construct a spanning tree? A. Yes. After choosing initial node in step 1, in each subsequent step we add one additional node and edge until all nodes are selected. Hence we have n nodes, and n-1 edges selected. Furthermore, the construction always connects an unconnected node to a connected node so the subgraph will also be connected. n nodes + n-1 edges + connected subgraph Spanning Tree. Q. Will this algorithm always construct a minimum spanning tree? A. Yes. Proof is not trivial. We will show this by examining certain properties of MST.
32
Lec 7
e.g. S = {1, 2, 3 ,4} edges across cut: {4,5}, {4,6}, {3,8}, {7,4}
Lec 7
e.g. S = {1, 2, 3 ,4} arcs out of cut: (4,5), (4,6), (3,8) arcs into cut: (7,4)
e.g. S = {1, 2, 3 ,4} edges across cut: {4,5}, {4,6}, {3,8}, {7,4}
33
Lec 7
e.g. S = {1, 2, 3 ,4, 7, 8} arcs out of cut: (4,5), (4,6), (7,10) arcs into cut: (5,7)
e.g. S = {1, 2, 3 ,4, 7, 8} edges across cut: {4,5}, {4,6}, {7,5}, {7,10}
Lec 7
e.g. S = {1, 2, 3 ,4, 7, 8, 5, 6} e.g. S = {1, 2, 3 ,4, 7, 8, 5 ,6} arcs out of cut: (6,9), (6,10), (5,10), (7,10) edges across cut: {6,9}, {6,10}, {5,10}, {7,10} arcs into cut: (10,6)
34
Lec 7
Lec 7
2 1 3 4 7 8 5
6 9 10 1
2 4 3 7 8 5
6 9 10
Spanning Tree
Remove edge {3,4} from spanning tree S = {1, 2, 3 ,8} edges across cut: {2,4}, {3,4}, {7,8}
2 1 3 4 7 8 5 10 6 9 1 3 2 4 7 8 5 10 6 9
35
Lec 7
2 1 3 4 7 8 5
6 9 10 1
2 4 3 7 8 5
6 9 10
Spanning Tree
Remove edge {4,6} from spanning tree S = {1, 2, 3 , 4, 5, 1 7, 8} edges across cut: {4,6}, {5,10}, {7,10}
2 4 3 7 8 5 10 6 9 1 3 2 4 7 8 5 10 6 9
Lec 7
2 1 3 4 7 8 5
6 9 10 1
2 4 3 7 8 5
6 9 10
Spanning Tree
Remove edge {4,6} from spanning tree S = {1, 2, 3 , 4, 5, 1 7, 8} edges across cut: {4,6}, {5,10}, {7,10}
2 4 3 7 8 5 10 6 9 1 3 2 4 7 8 5 10 6 9
Q. Why does removing an edge break a spanning tree into exactly two components? A. What does it mean if removing edge did not result in a disconnected graph? What does it mean if removing edge results in more than 2 disconnected components?
36
Lec 7
Lec 7
2 1 3 4 7 8 5
6 9 10 1
2 4 3 7 8 5
6 9 10
Spanning Tree
Remove edge {3,4} and replace with {7,8} S = {1, 2, 3 ,8} edges across cut: {2,4}, {3,4}, {7,8}
2 1 3 4 7 8 5 10 6 9 1 3 2 4 7 8 5 10 6 9
37
Lec 7
2 1 3 4 7 8 5
6 9 10 1
2 4 3 7 8 5
6 9 10
Spanning Tree
Remove edge {4,6} and replace with {7,10} S = {1, 2, 3 , 4, 5, 1 7, 8} edges across cut: {4,6}, {5,10}, {7,10}
2 4 3 7 8 5 10 6 9 1 3 2 4 7 8 5 10 6 9
Lec 7
2 1 3 4 7 8 5
6 9 10 1
2 4 3 7 8 5
6 9 10
Spanning Tree
Remove edge {4,6} and replace with {7,10} S = {1, 2, 3 , 4, 5, 1 7, 8} edges across cut: {4,6}, {5,10}, {7,10}
2 4 3 7 8 5 10 6 9 1 3 2 4 7 8 5 10 6 9
Q. Why does replacing edges across a cut lead to another spanning tree? A. We start with n nodes and n-1 edge, then remove an edge and replace with another edge. Since both edges cross the same cut, the graph will be connected.
38
Lec 7
Lec 7
Undirected Graph
Subgraph
2 1 3 4 7 8 5
6 9 10 1
2 4 3 7 8 5
6 9 10
Spanning Tree T
For T to be an MST, we must have: c1,2 < c2,3, c1,2 < c2,4
39
Lec 7
Undirected Graph
Subgraph
2 1 3 4 7 8 5
6 9 10 1
2 4 3 7 8 5
6 9 10
Spanning Tree T
For T to be an MST, we must have: c1,2 < c2,3, c1,2 < c2,4 c1,3 < c2,3, c1,3 < c2,4
Lec 7
Undirected Graph
Subgraph
2 1 3 4 7 8 5
6 9 10 1
2 4 3 7 8 5
6 9 10
Spanning Tree T
For T to be an MST, we must have: c1,2 < c2,3, c1,2 < c2,4 c1,3 < c2,3, c1,3 < c2,4 c3,4 < c2,4, c3,4 < c8,7
40
Lec 7
Undirected Graph
Subgraph
2 1 3 4 7 8 5
6 9 10 1
2 4 3 7 8 5
6 9 10
Spanning Tree T
For T to be an MST, we must have: c1,2 < c2,3, c1,2 < c2,4 c1,3 < c2,3, c1,3 < c2,4 c3,4 < c2,4, c3,4 < c8,7 c4,6 < c5,10, c4,6 < c7,10 :
Lec 7
Proof: First, show that if T does not satisfy the cut optimality condition, then T cannot be an MST:
From property 2 we know that we can replace an edge {i,j} belonging to T with another edge {k,l} across the cut induced by {i,j} and obtain another spanning tree. Hence, if cij > ckl, then the new tree obtained by replacing {i,j} with {k,l} will have lower cost T cannot be an MST.
Second, show that if T satisfies the cut optimality condition, then T must be an MST:
Suppose T satisfies the cut optimality condition and let T* be an MST. We show that T and T* must have the same cost and thus, T must also be optimal. Let {i,j} be an edge in T but not in T*. Consider the cut induced by {i,j}. Since T* is connected, there must be an edge {k,l} in T* that crosses this cut. Since T satisfies the optimality condition we must have cij < ckl. If cij < ckl, then we could improve T* and therefore cij = ckl. We can repeat this until T is the same as T*. Note that each time we replace an edge in T with an edge in T* with the same cost and hence T and T* must have the same cost.
41
Lec 7
Proof: First, show that if T does not satisfy the cut optimality condition, then T cannot be an MST:
From property 2 we know that we can replace an edge {i,j} belonging to T with another edge {k,l} across the cut induced by {i,j} and obtain another spanning tree. Hence, if cij > ckl, then the new tree obtained by replacing {i,j} with {k,l} will have lower cost T cannot be an MST.
Second, show that if T satisfies the cut optimality condition, then T must be an MST:
Suppose T satisfies the cut optimality condition and let T* be an MST. We show that T and T* must have the same cost and thus, T must also be optimal. Let {i,j} be an edge in T but not in T*. Consider the cut induced by {i,j}. Since T* is connected, there must be an edge {k,l} in T* that crosses this cut. Since T satisfies the optimality condition we must have cij < ckl. If cij < ckl, then we could improve T* and therefore cij = ckl. We can repeat this until T is the same as T*. Note that each time we replace an edge in T with an edge in T* with the same cost and hence T and T* must have the same cost.
Lec 7
Proof: First, show that if T does not satisfy the cut optimality condition, then T cannot be an MST:
From property 2 we know that we can replace an edge {i,j} belonging to T with another edge {k,l} across the cut induced by {i,j} and obtain another spanning tree. Hence, if cij > ckl, then the new tree obtained by replacing {i,j} with {k,l} will have lower cost T cannot be an MST.
Second, show that if T satisfies the cut optimality condition, then T must be an MST:
Suppose T satisfies the cut optimality condition and let T* be an MST. We show that T and T* must have the same cost and thus, T must also be optimal. Let {i,j} be an edge in T but not in T*. Consider the cut induced by {i,j}. Since T* is connected, there must be an edge {k,l} in T* that crosses this cut. Since T satisfies the optimality condition we must have cij < ckl. If cij < ckl, then we could improve T* and therefore cij = ckl. We can repeat this until T is the same as T*. Note that each time we replace an edge in T with an edge in T* with the same cost and hence T and T* must have the same cost.
42
Lec 7
Proof: First, show that if T does not satisfy the cut optimality condition, then T cannot be an MST:
From property 2 we know that we can replace an edge {i,j} belonging to T with another edge {k,l} across the cut induced by {i,j} and obtain another spanning tree. Hence, if cij > ckl, then the new tree obtained by replacing {i,j} with {k,l} will have lower cost T cannot be an MST.
Second, show that if T satisfies the cut optimality condition, then T must be an MST:
Suppose T satisfies the cut optimality condition and let T* be an MST. We show that T and T* must have the same cost and thus, T must also be optimal. Let {i,j} be an edge in T but not in T*. Consider the cut induced by {i,j}. Since T* is connected, there must be an edge {k,l} in T* that crosses this cut. Since T satisfies the optimality condition we must have cij < ckl. If cij < ckl, then we could improve T* and therefore cij = ckl. We can repeat this until T is the same as T*. Note that each time we replace an edge in T with an edge in T* with the same cost and hence T and T* must have the same cost.
Lec 7
4.
Q. Will Prims algorithm always construct a minimum spanning tree? A. Yes. If Prims algorithm did not construct an MST, then from the cut optimality condition of MST, there would be an edge {i,j} in the spanning tree constructed by the algorithm that can be replaced by another edge {k,l} that crosses the cut induced by {i,j} and with lower cost (i.e. ckl < cij). Hence, swapping {i,j} with {k,l} would lead to a better spanning tree. However, if ckl < cij then step 3 of the algorithm would have chosen {k,l} as the nearest connection between connected and unconnected nodes and not {i,j}. Hence, Prims algorithm must construct an MST.
43
Lec 7
4.
Connected nodes
Unconnected nodes
Lec 7
4.
Q. Will Prims algorithm always construct a minimum spanning tree? A. Yes. If Prims algorithm did not construct an MST, then from the cut optimality condition of MST, there would be an edge {i,j} in the spanning tree constructed by the algorithm that can be replaced by another edge {k,l} that crosses the cut induced by {i,j} and with lower cost (i.e. ckl < cij). Hence, swapping {i,j} with {k,l} would lead to a better spanning tree. However, if ckl < cij then step 3 of the algorithm would have chosen {k,l} as the nearest connection between connected and unconnected nodes and not {i,j}. Hence, Prims algorithm must construct an MST.
44