Question

Say that we have an undirected graph G(V, E) and a pair of vertices s, t and a vertex v that we call a a desired middle vertex . We wish to find out if there exists a simple path (every vertex appears...

Say that we have an undirected graph G(V, E) and a pair of vertices s, t and a vertex v that we call a a desired middle vertex . We wish to find out if there exists a simple path (every vertex appears at most once) from s to t that goes via v.

Create a flow network by making v a source. Add a new vertex Z as a sink. Join s, t with two directed edges of capacity 1 to the sink Z. Replace every edge in the graph by two anti parallel edges. Give all edges capacity 1, Check if there is a flow from v to z of value 2. If there is we answer yes on the path question, and else we answer no. Is the algorithm correct? If it is not, how should we change it to be correct?

Does this algorithm work for the directed case? If yes, explain and if not explain why not.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

No this approach will not work. The reason is that flow from v to Z via node t and the flow from v to Z via node s may share some common vertex and we want simple path without any vertex sharing.

To make this algorithm work, we have to simply add a flow constraint that every vertices in graph , amount of flow passed through it should be almost 1 unit. If we impose this constrain then path from v to Z via s and v to Z via t will be vertex disjoint and hence the path returned by them will be simple path and hence it 2 unit flow is there from v to Z then the required solution is met.

No this approach will not work for directed graph because even if flow value of 2 unit is there from v to Z and hence two vertex disjoint paths exist from s to Z, still this does not means that there exist path from s to v because it's directed graph while in undirected case, path from v to s exist also mean that path from s to v exist, this does not always happen in directed graph. Hence this approach will not work.

Hence this algorithm is correct.

Please comment for any clarification.

Add a comment
Know the answer?
Add Answer to:
Say that we have an undirected graph G(V, E) and a pair of vertices s, t and a vertex v that we call a a desired middle vertex . We wish to find out if there exists a simple path (every vertex appears...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Let G = (V;E) be an undirected and unweighted graph. Let S be a subset of the vertices. The graph...

    Let G = (V;E) be an undirected and unweighted graph. Let S be a subset of the vertices. The graph induced on S, denoted G[S] is a graph that has vertex set S and an edge between two vertices u, v that is an element of S provided that {u,v} is an edge of G. A subset K of V is called a killer set of G if the deletion of K kills all the edges of G, that is...

  • Viterbi algorithm We can use dynamic programming on a directed graph G = (V, E) for...

    Viterbi algorithm We can use dynamic programming on a directed graph G = (V, E) for speech recognition. Each edge (u, v) in E is labeled with a sound s(u, v) from a finite set S of sounds. The labeled graph is a formal model of a person speaking a restricted language. Each path in the graph starting from a distinguished vertex v0 in V corresponds to a possible sequence of sounds produced by the model. The label of a...

  • 2. Let G = (V, E) be an undirected connected graph with n vertices and with...

    2. Let G = (V, E) be an undirected connected graph with n vertices and with an edge-weight function w : E → Z. An edge (u, v) ∈ E is sparkling if it is contained in some minimum spanning tree (MST) of G. The computational problem is to return the set of all sparkling edges in E. Describe an efficient algorithm for this computational problem. You do not need to use pseudocode. What is the asymptotic time complexity of...

  • Consider a directed acyclic graph G = (V, E) without edge lengths and a start vertex...

    Consider a directed acyclic graph G = (V, E) without edge lengths and a start vertex s E V. (Recall, the length of a path in an graph without edge lengths is given by the number of edges on that path). Someone claims that the following greedy algorithm will always find longest path in the graph G starting from s. path = [8] Ucurrent = s topologically sort the vertices V of G. forall v EV in topological order do...

  • Let G = (V, E, w) be a connected weighted undirected graph. Given a vertex s...

    Let G = (V, E, w) be a connected weighted undirected graph. Given a vertex s ∈ V and a shortest path tree Ts with respect to the source s, design a linear time algorithm for checking whether the shortest path tree Ts is correct or not.(C pseudo)

  • 10. You are given a directed graph G(V, E) where every vertex vi E V is...

    10. You are given a directed graph G(V, E) where every vertex vi E V is associated with a weight wi> 0. The length of a path is the sum of weights of all vertices along this path. Given s,t e V, suggest an O((n+ m) log n) time algorithm for finding the shortest path m s toO As usual, n = IVI and m = IEI.

  • Consider the following weighted, directed graph G. There are 7 vertices and 10 edges. The edge list E is as follows:

    Consider the following weighted, directed graph G. There are 7 vertices and 10 edges. The edge list E is as follows:The Bellman-Ford algorithm makes |V|-1 = 7-1 = 6 passes through the edge list E. Each pass relaxes the edges in the order they appear in the edge list. As with Dijkstra's algorithm, we record the current best known cost D[V] to reach each vertex V from the start vertex S. Initially D[A]=0 and D[V]=+oo for all the other vertices...

  • Input a simple undirected weighted graph G with non-negative edge weights (represented by w), and a...

    Input a simple undirected weighted graph G with non-negative edge weights (represented by w), and a source node v of G. Output: TDB. D: a vector indexed by the vertices of G. Q: priority queue containing the vertices of G using D[] as key D[v]=0; for (all vertex ut-v) [D[u]-infinity:) while not Q. empty() 11 Q is not empty fu - Q.removein(); // retrieve a vertex of Q with min D value for (all vertex : adjacent to u such...

  • Let G (V, E) be a directed graph with n vertices and m edges. It is known that in dfsTrace of G t...

    Let G (V, E) be a directed graph with n vertices and m edges. It is known that in dfsTrace of G the function dfs is called n times, once for each vertex It is also seen that dfs contains a loop whose body gets executed while visiting v once for each vertex w adjacent to v; that is the body gets executed once for each edge (v, w). In the worst case there are n adjacent vertices. What do...

  • Suppose we are given a directed acyclic graph G with a unique source and a unique...

    Suppose we are given a directed acyclic graph G with a unique source and a unique sink t. A vertex v ¢ {s,t} is called an (s,t)-cut vertex if every path from s to t passes through v, or equivalently, if deleting v makes t unreachable from s. Describe and analyze an algorithm to find every (s, t)-cut vertex in G t

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT