maximum flows of minimum cost
TRANSCRIPT
![Page 1: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/1.jpg)
Data Structures and Algorithms in Java 1
Maximum Flows of Minimum Cost
Figure 8-24 Two possible maximum flows for the same network
![Page 2: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/2.jpg)
Data Structures and Algorithms in Java 2
Maximum Flows of Minimum Cost (continued)
Figure 8-25 Finding a maximum flow of minimum cost
![Page 3: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/3.jpg)
Data Structures and Algorithms in Java 3
Maximum Flows of Minimum Cost (continued)
Figure 8-25 Finding a maximum flow of minimum cost (continued)
![Page 4: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/4.jpg)
Data Structures and Algorithms in Java 4
Maximum Flows of Minimum Cost (continued)
Figure 8-25 Finding a maximum flow of minimum cost (continued)
![Page 5: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/5.jpg)
Data Structures and Algorithms in Java 5
Matching
• Maximum matching is a matching that contains a maximum number of edges so that the number of unmatched vertices (that is, vertices not incident with edges in M) is minimal
• A matching problem consists in finding a maximum matching for a certain graph G
• The problem of finding a perfect matching is also called the marriage problem
![Page 6: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/6.jpg)
Data Structures and Algorithms in Java 6
Matching (continued)
Figure 8-26 Matching five applicants with five jobs
![Page 7: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/7.jpg)
Data Structures and Algorithms in Java 7
Matching (continued)
Figure 8-27 A graph with matchings M1 = {edge(ab), edge(ef)} andM2 = {edge(ab), edge(de), edge(fh)}
![Page 8: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/8.jpg)
Data Structures and Algorithms in Java 8
Matching (continued)
Figure 8-28 (a) Two matchings M and N in a graph G = (V,E) and (b) the graph G′ = (V, M N)
![Page 9: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/9.jpg)
Data Structures and Algorithms in Java 9
Matching (continued)
Figure 8-29 (a) Augmenting path P and a matching M and (b) the matching M P
![Page 10: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/10.jpg)
Data Structures and Algorithms in Java 10
Matching (continued)
Figure 8-30 Application of the findMaximumMatching() algorithm. Matched vertices are connected with solid lines.
![Page 11: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/11.jpg)
Data Structures and Algorithms in Java 11
Matching (continued)
Figure 8-30 Application of the findMaximumMatching() algorithm. Matched vertices are connected with solid lines (continued).
![Page 12: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/12.jpg)
Data Structures and Algorithms in Java 12
Assignment Problem
Figure 8-31 An example of application of the optimalAssignment()algorithm
![Page 13: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/13.jpg)
Data Structures and Algorithms in Java 13
Matching in Nonbipartite Graphs
Figure 8-32 Application of the findMaximumMatching() algorithm to a nonbipartite graph
![Page 14: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/14.jpg)
Data Structures and Algorithms in Java 14
Matching in Nonbipartite Graphs (continued)
Figure 8-33 Processing a graph with a blossom
![Page 15: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/15.jpg)
Data Structures and Algorithms in Java 15
Matching in Nonbipartite Graphs (continued)
Figure 8-33 Processing a graph with a blossom (continued)
![Page 16: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/16.jpg)
Data Structures and Algorithms in Java 16
Eulerian Graphs
• An Eulerian trail in a graph is a path that includes all edges of the graph only once
• An Eulerian cycle is a cycle that is also an Eulerian trail
• A graph that has an Eulerian cycle is called an Eulerian graph
![Page 17: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/17.jpg)
Data Structures and Algorithms in Java 17
Eulerian Graphs (continued)
Figure 8-34 Finding an Eulerian cycle
![Page 18: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/18.jpg)
Data Structures and Algorithms in Java 18
The Chinese Postman Problem
Figure 8-35 Solving the Chinese postman problem
![Page 19: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/19.jpg)
Data Structures and Algorithms in Java 19
The Chinese Postman Problem
Figure 8-35 Solving the Chinese postman problem (continued)
![Page 20: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/20.jpg)
Data Structures and Algorithms in Java 20
The Chinese Postman Problem
Figure 8-35 Solving the Chinese postman problem (continued)
![Page 21: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/21.jpg)
Data Structures and Algorithms in Java 21
The Chinese Postman Problem
Figure 8-35 Solving the Chinese postman problem (continued)
![Page 22: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/22.jpg)
Data Structures and Algorithms in Java 22
Hamiltonian Graphs
• A Hamiltonian cycle in a graph is a cycle that passes through all the vertices of the graph
• A graph is called a Hamiltonian graph if it includes at least one Hamiltonian cycle
![Page 23: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/23.jpg)
Data Structures and Algorithms in Java 23
Hamiltonian Graphs (continued)
Figure 8-36 Crossover edges
![Page 24: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/24.jpg)
Data Structures and Algorithms in Java 24
Hamiltonian Graphs (continued)
Figure 8-37 Finding a Hamiltonian cycle
![Page 25: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/25.jpg)
Data Structures and Algorithms in Java 25
Hamiltonian Graphs (continued)
Figure 8-37 Finding a Hamiltonian cycle (continued)
![Page 26: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/26.jpg)
Data Structures and Algorithms in Java 26
The Traveling Salesman Problem
Figure 8-38 Using a minimum spanning tree to find a minimum salesman tour
![Page 27: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/27.jpg)
Data Structures and Algorithms in Java 27
The Traveling Salesman Problem (continued)
Figure 8-38 Using a minimum spanning tree to find a minimum salesman tour (continued)
![Page 28: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/28.jpg)
Data Structures and Algorithms in Java 28
The Traveling Salesman Problem (continued)
Figure 8-38 Using a minimum spanning tree to find a minimum salesman tour (continued)
![Page 29: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/29.jpg)
Data Structures and Algorithms in Java 29
The Traveling Salesman Problem (continued)
Figure 8-39 Applying the nearest insertion algorithm to the cities in Figure 8.38a
![Page 30: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/30.jpg)
Data Structures and Algorithms in Java 30
The Traveling Salesman Problem (continued)
Figure 8-39 Applying the nearest insertion algorithm to the cities in Figure 8.38a (continued)
![Page 31: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/31.jpg)
Data Structures and Algorithms in Java 31
Graph Coloring
• Sequential coloring establishes the sequence of vertices and a sequence of colors before coloring them, and then color the next vertex with the lowest number possible
sequentialColoringAlgorithm(graph = (V, E))put vertices in a certain order vP1, vP2, . . . , vPv ;
put colors in a certain order cP1, c2, . . . , ck;for i = 1 to |V|
j = the smallest index of color that does not appear in any neighbor of vPi;color(vPi) = cj;
![Page 32: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/32.jpg)
Data Structures and Algorithms in Java 32
Graph Coloring (continued)
Figure 8-40 (a) A graph used for coloring; (b) colors assigned to vertices with the sequential coloring algorithm that orders vertices by index number; (c) vertices are put in the largest first sequence; (d) graph coloring obtained with the Brélaz algorithm
![Page 33: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/33.jpg)
Data Structures and Algorithms in Java 33
The Clique Problem
Figure 8-41 A graph corresponding to Boolean expression
![Page 34: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/34.jpg)
Data Structures and Algorithms in Java 34
The 3-Colorability Problem
Figure 8-42 (a) A 9-subgraph; (b) a graph corresponding to Boolean expression
![Page 35: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/35.jpg)
Data Structures and Algorithms in Java 35
The Vertex Cover Problem
Figure 8-43 (a) A graph with a clique; (b) a complement graph
![Page 36: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/36.jpg)
Data Structures and Algorithms in Java 36
The Hamiltonian Cycle Problem
Figure 8-44 (a) A 12-subgraph; (b) a graph G and (c) its transformation, graph GH
![Page 37: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/37.jpg)
Data Structures and Algorithms in Java 37
The Hamiltonian Cycle Problem
Figure 8-44 (a) A 12-subgraph; (b) a graph G and (c) its transformation, graph GH (continued)
![Page 38: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/38.jpg)
Data Structures and Algorithms in Java 38
Case Study: Distinct Representatives
Figure 8-45 (a) A network representing membership of three committees, C1, C2, and C3, and (b) the first augmenting path found in this network
![Page 39: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/39.jpg)
Data Structures and Algorithms in Java 39
Case Study: Distinct Representatives (continued)
Figure 8-46 The network representation created by FordFulkersonMaxFlow()
![Page 40: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/40.jpg)
Data Structures and Algorithms in Java 40
Case Study: Distinct Representatives (continued)
Figure 8-47 An implementation of the distinct representatives problem
![Page 41: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/41.jpg)
Data Structures and Algorithms in Java 41
Case Study: Distinct Representatives (continued)
Figure 8-47 An implementation of the distinct representatives problem(continued)
![Page 42: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/42.jpg)
Data Structures and Algorithms in Java 42
Case Study: Distinct Representatives (continued)
Figure 8-47 An implementation of the distinct representatives problem(continued)
![Page 43: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/43.jpg)
Data Structures and Algorithms in Java 43
Case Study: Distinct Representatives (continued)
Figure 8-47 An implementation of the distinct representatives problem(continued)
![Page 44: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/44.jpg)
Data Structures and Algorithms in Java 44
Case Study: Distinct Representatives (continued)
Figure 8-47 An implementation of the distinct representatives problem(continued)
![Page 45: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/45.jpg)
Data Structures and Algorithms in Java 45
Case Study: Distinct Representatives (continued)
Figure 8-47 An implementation of the distinct representatives problem(continued)
![Page 46: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/46.jpg)
Data Structures and Algorithms in Java 46
Case Study: Distinct Representatives (continued)
Figure 8-47 An implementation of the distinct representatives problem(continued)
![Page 47: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/47.jpg)
Data Structures and Algorithms in Java 47
Case Study: Distinct Representatives (continued)
Figure 8-47 An implementation of the distinct representatives problem(continued)
![Page 48: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/48.jpg)
Data Structures and Algorithms in Java 48
Case Study: Distinct Representatives (continued)
Figure 8-47 An implementation of the distinct representatives problem(continued)
![Page 49: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/49.jpg)
Data Structures and Algorithms in Java 49
Case Study: Distinct Representatives (continued)
Figure 8-47 An implementation of the distinct representatives problem(continued)
![Page 50: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/50.jpg)
Data Structures and Algorithms in Java 50
Case Study: Distinct Representatives (continued)
Figure 8-47 An implementation of the distinct representatives problem(continued)
![Page 51: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/51.jpg)
Data Structures and Algorithms in Java 51
Case Study: Distinct Representatives (continued)
Figure 8-47 An implementation of the distinct representatives problem(continued)
![Page 52: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/52.jpg)
Data Structures and Algorithms in Java 52
Case Study: Distinct Representatives (continued)
Figure 8-47 An implementation of the distinct representatives problem(continued)
![Page 53: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/53.jpg)
Data Structures and Algorithms in Java 53
Summary
• A graph is a collection of vertices (or nodes) and the connections between them
• A multigraph is a graph in which two vertices can be joined by multiple edges
• A pseudograph is a multigraph with the condition vi ≠ vj removed, which allows for loops to occur
• The sets used to solve the union-find problem are implemented with circular linked lists
![Page 54: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/54.jpg)
Data Structures and Algorithms in Java 54
Summary (continued)
• A spanning tree is an algorithm that guarantees generating a tree (or a forest, a set of trees) that includes or spans over all vertices of the original graph
• An undirected graph is called connected when there is a path between any two vertices of the graph
• A network is a digraph with one vertex s, called the source, with no incoming edges, and one vertex t, called the sink, with no outgoing edges
![Page 55: Maximum Flows of Minimum Cost](https://reader034.vdocuments.site/reader034/viewer/2022042522/626203ca2746d57f1e661759/html5/thumbnails/55.jpg)
Data Structures and Algorithms in Java 55
Summary (continued)
• Maximum matching is a matching that contains a maximum number of edges so that the number of unmatched vertices (that is, vertices not incident with edges in M) is minimal
• A Hamiltonian cycle in a graph is a cycle that passes through all the vertices of the graph
• Sequential coloring establishes the sequence of vertices and a sequence of colors before coloring them, and then color the next vertex with the lowest number possible