Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Solving Arbitrage and Maximum-Weight Independent Set Problems using Graph Algorithms, Assignments of Computer Science

Solutions to two problems: the arbitrage problem and the maximum-weight independent set problem. The arbitrage problem is solved using a graph algorithm, specifically the bellman-ford algorithm, to identify a negative-weight cycle representing a profitable conversion sequence. The maximum-weight independent set problem is solved using dynamic programming, where the solution for smaller subproblems is used to find the maximum-weight independent set for a larger problem. The document also includes instructions on how to extract the actual sequence of vertices in a negative-weight cycle and the independent set itself.

Typology: Assignments

Pre 2010

Uploaded on 07/31/2009

koofers-user-9hw
koofers-user-9hw 🇺🇸

10 documents

1 / 2

Toggle sidebar

Related documents


Partial preview of the text

Download Solving Arbitrage and Maximum-Weight Independent Set Problems using Graph Algorithms and more Assignments Computer Science in PDF only on Docsity! Solutions HW5 Nina Amenta ECS 122A 1. a) We express the arbitrage problem in terms of a graph with weights on the edges. Each currency is represented by a vertex in the graph. Since we can convert from any currency to any other, our graph contains all possible edges between two currencies. We want to find a profitable conversion sequence by some how assigning weights to the edges so that a profitable conversion sequence shows up as a negative- weight cycle. The length of a shortest path in a graph is expressed as the sum of the edge weights in the path, while the rate of profit on a cycle in our graph is expressed as a product of conversion rates. But we know that R[i1, i2]R[i2, i3] · · ·R[ik−1, ik] > 1 iff lg R[i1, i2] + lg R[i2, i3] + . . . + lg R[ik−1, ik] > lg 1 = 0 In other words, if we assign a weight of lg R[i, j] to each edge, a profitable cycle is a positive-weight cycle. If instead we assign a weight w(i, j) = − lg R[i, j] to each edge (i, j), a profitable cycle appears as a negative- weight cycle in the graph. To find out if the graph contains a negative-weight cycle, we run the Bellman-Ford algorithm, and then test each edge (i, j) to see if d(j) > d(i) + w(i, j). If this is true for any edge, then we know the graph contains a negative-weight cycle. b) To actually print out the sequence of vertices in some negative-weight cycle, we need to store extra information with the shortest-paths, just as we did in some of the dynamic programming algorithms. We keep an array of predecessor pointers p(i), along with the path-weight matrix d(i). Every p(i) is initialized to NULL. When running the Bellman-Ford algorithm, each time we reduce the path length to vertex vj by setting d(j)← d(i) + w(i, j), we set p(j)← i, to indicate that the shortest path found so far to vj ends with edge (i, j). The predecessor pointers define a graph on the vertices. Claim: After we have run the Bellman-Ford algorithm, any cycle in the graph defined by the predecessor poitners is a negative-weight cycle. Proof: Consider the last edge (i, j) in the cycle for which p(j) was set by RELAXing edge (i, j). Let (j, k) be the next edge in the cycle. Since the value d(j) was reduced since d(k) was set, we could reduce d(k)by setting it equal to d(j) + w(j, k). Similarly we can reduce the d() value for every vertex in the cycle, finally reducing d(i) and demonstrating that this is a negative-weight cycle. To find a cycle in the graph of predecessor pointers, we can use depth-first search. 2. No, a shortest path with respect to W ′ is not necessarily a shortest path with respect to W . For instance, in the graph below, the shortest path with respect to W has length one, while the shortest path with respect to W ′ is a different path and has length five. -3 4 2 s v 3. We can find a maximum-weight independent set using dynamic programming. We consider the subproblems of finding a maximum-weight independent set in graphs {(v1, v2), (v2, v3), . . . , (vk−1, vk)}. Call the solution 1
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved