Alg Des Ch06: Weighted Graph Algorithms

Ace your homework & exams now with Quizwiz!

What is the take-home lesson for solving problems with graphs?

"Designing novel graph algorithms is very hard, so don't do it. Instead, try to design graphs that enable you to use classical algorithms to model your problem."

What are 3 easy applications of Minimum Spanning Trees?

1) Maximum Spanning Trees (use Prim's algorithm with negative weights), 2) Minimum Product Spanning Trees (replace weights with their logarithm) and 3) Minimum Bottleneck Spanning Trees (just use Kruskal's algorithm, since by it's nature it chooses the lowest weight edges).

How can Dijkstra's algorithm be used if the weights are on the vertices instead of the edges?

2 options. Option 1 is to modify the algorithm by replacing references to edge weights with references to the weights of the destination vertices. Option 2 is to construct the edge weight graph by defining the weight of each directed edge (x,y) as the weight of vertex y. Then use regular Dijkstra's.

What does it mean if a graph if Bipartite or Two-Colorable? 3 Examples?

A graph is Bipartite if the vertices can be divided into two sets, L and R, such that all edges in G have one vertex in L and one vertex in R; no 2 same-group vertices can share an edge, or "be adjacent". (This is almost the complement of a matching, where the edges form a group, and no two edges in the same matching can share a vertex, or "be adjacent".) Like a Matching, the two groups L and R are often of two different types, but here they represent "potential" pairings, such as specific tasks/jobs and people who can do them, or boys with girls with whom they are compatible. Often we will then seek the matching with the greatest number of pairings.

What is a Matching in a graph?

A subset of edges such that no two edges in the subset share a vertex. Think of these as pairings. The vertices on either side are often interpreted as different types, such as jobs with people to do them, and boys with girls to marry. Each vertex can be in at most 1 pair.

When finding the maximum network flow from source to sink, what is an Augmenting Path and why are such paths important?

An Augmenting Path is a path of positive capacity on the Residual Flow Graph, indicating the path has not yet been included in the flow. It can be shown that the flow through a network is optimal if and only if it contains no augmenting path.

What is an s-t cut, and how does this relate to finding the maximum network flow?

An s-t cut is a set of edges whose deletion separates s from t. The maximum flow from s to t always equals the weight of the minimum s-t cut.

How are the proofs of the correctness of Prim's and Kruskal's algorithms consructed?

By contradiction. At some point an edge (x,y) is added that is wrong. It is shown that swapping this into the "correct" Minimum Spanning Tree can maintain, or even decrease the total weight of the graph. This contradicts the assumption that the algorithm made a wrong decision.

For a given Bipartite graph, how can the Matching with the largest weight sum be found?

Connect all L nodes to an additional "source" node and all R nodes to an additional "sink" node. Find the maximum possible flow from source to sink, with all edges having weight 1. The edges included will be the maximum Matching.

If given a flow f through a graph G, what is the Residual Flow Graph R(G,f)?

For each i and j, f(i,j) is subtracted from each capacity c(i,j). Same for f(j,i) subtracted from c(j,i). Note that f(i,j) = -f(j,i). Edges represent the additional capacity to increase flow in the given direction.

How does Prim's algorithm find the next edge to add?

For every non-tree vertex, it keeps track of the cheapest edge that could connect it to the tree. Every time the next cheapest edge is added into the tree, the edges from the new vertex are used to updated the other cheapest possible additional edges.

Explain Dijkstra's algorithm for a weighted graph?

Given a starting vertex s, the algorithm finds the shortest path to every other vertex in a way almost identical to Prim's algorithm. Vertices are added sequentially to the tree. The distance from s to every other non-tree vertex t is tracked, specifically as the sum of the distance from s to some other tree node v, plus the weight of a direct edge from v to t, infinity if none exists. At each stage, the non-tree vertex the smallest distance from s is added and the information on all other non-tree nodes is updated.

What is the crucial difference between Prim's algorithm and Dijkstra's algorithm.

How they rate the desirability of each outside vertex. In the minimum spanning tree problem, all we cared about was the weight of the next potential tree edge. In the shortest path, we want to add the closest outside vertex to the starting vertex. This is a function of both the new edge weight and the distance from the starting vertex to the tree vertex it is adjacent to.

What is the transitive closure of a graph? What are 2 analogies?

If an edge (x,y) in the original graph means that y can be reached directly from x, then an edge (x,y) in the transitive closure means that y can be reached from x (taking as many edges as needed). I.e., the transitive closure represents whether it is possible to reach one node from another. One analogy is plane flights, with original edges indicating direct flights, and transitive closure edges meaning where you can possibly travel to in any number of flights. Another analogy is blackmail: "who has dirt on who". I may only have dirt on Miguel, but Miguel may have dirt on 10 other guys. So in theory, I can blackmail them too by blackmailing Miguel. How can interpreting English sentences typed on a keypad be interpreted as a graph problem?

What is Kruskal's algorithm for finding a Minimum Spanning Tree of a weighted graph?

Initially, each vertex forms its own separate component in the tree-to-be. All edges are put on a priority queue ordered by weight. Repeatedly, vertices for the cheapest edge are checked if they are already part of the same component. If not, the edge is added to the tree, merging those two components. Otherwise, it's discarded. When n-1 edges have been added, all vertices will be in the same component, or tree.

What is a Spanning Tree for a graph? What is a Minimum Spanning Tree?

It is a subset of edges forming a tree connecting all the vertices of the graph. The Spanning Tree is Minimum when the sum of edge weights is as small as possible.

In broad terms, how does the Ford-Fulkerson algorithm find the Maximum Network Flow of a graph? What is its running time?

It repeatedly uses BFS to find the shortest path from source to sink on the Residual Flow Network. Then it finds the minimum weight edge along that path and updates the Residual Flow Network. Because the shortest path is always used as the augmenting path, it has been shown that this leads to O(n^3) running time.

Which algorithm is better on sparse or dense graphs?

Prim's is O(m + n log n), and so can even be linear on dense graphs. Kruskal's is O(m log m) and so performs better on sparse graphs.

What 2 operations are simultaneously optimized in the Union-Find data structure? Describe the structure?

Same Component and Merge Components. The components are structured as reverse trees, with pointers to parents. Roots identify components. The Find operation determines the root, and therefore the component, in O(log n). The Union operation combines two trees by having the smaller tree's root point to the root of the larger tree, in O(log n). Path compression can make these operations even faster (nearly linear).

What is the running time of Dijkstra's algorithm?

Same as Prim's. O(n^2), or O(m + n log n) if implemented with a Priority Queue.

What is Prim's algorithm for finding a Minimum Spanning Tree of a weighted graph?

Select an arbitrary vertex. Then for each iteration, add the edge of minimum weight between a tree and non-tree vertex.

Why is the basic version of Kruskal's algorithm O(m log m) followed by O(mn)? How is this reduced to O(m log m)?

Sorting all m edges (placing them on the queue) is m log m. Then up to m of them need to be checked and possibly added to the tree, and each time involves an O(n) search to check if the two vertices are already part of the same component. Using a Union-Find data structure speeds this up to O(log n). Since n is bounded by m, this is written as O(log m) so that the total running time becomes O(m log m + m log m) = O(m log m).

What does the Floyd-Warshall algorithm construct, and how does it do it?

The algorithm assigns each node a number k from 1 to n and constructs an n by n distance matrix, where element D(k)[i,j] is the shortest-path distance from i to j using only nodes 1 through k as possible intermediate vertices. When k=1, this is the original adjacency matrix. When k=n, this is the shortest-path distance matrix. Each kth iteration is computed easily in terms of the previous matrix, since the current shortest path (i-j) only needs to be compared with the path (i-k-j).

What is the diameter of a graph?

The largest shortest-path distance between any two points.

What is the Network Flow Problem?

What is the maximum amount of flow which can be sent from vertices s to t in a given weighted graph G while respecting the maximum capacities of each pipe (edge).

Why is the basic version of Prim's algorithm O(n^2)? And what is the idea that allows this to be sped up to O(m + n log n)?

n vertices are added, and for each addition the <n edges of the new vertex are updated, and the <n vertices not in the tree are then considered for being added next. These last two things are sequential, not nested, so together they are still O(n). Inside the outer O(n) loop makes O(n^2). Priority queues are used for faster performance: O(m) is probably putting all m edges on a heap, O(n log n) to find the cheapest new edge, n times.


Related study sets

CH09 - Contract Clauses and Their Administration

View Set

Chapter 6- Qualified Plans and Federal Tax Considerations

View Set

Lenexa SPG BOOK Phase 3: 200-END

View Set

Practice Test - Radiology Boards Prep

View Set

Practice course test for Testing planning, management, and tool support

View Set

Chapter 18: Cardiovascular System II: The Blood Vessels

View Set