-2

How can the maximum flow of a graph be computed when all nodes of the graph are connected to both sink and source nodes (two hypothetical nodes), and the maximum flow method should ignore such paths as $\text{source} \to \text{node} \to \text{sink}$, where $\to$ is a single edge?

A valid path containing a positive flow can be $source \to v$, $v \to w$, and $w \to sink$ where $v \neq{w}$.

I am not sure whether it's helpful, but the graph is a DAG (directed acyclic graph).

beginner1010
  • 168
  • 7
  • What have you considered or tried? Have you tried seeing whether the standard Ford-Fulkerson framework can be adapted to this situation? Have you considered enumerating all such paths and then doing something with them, e.g., forming a linear program? What do you mean by "should not count such paths"? Can you give a more precise specification of the problem? Is the only requirement that the flow be decomposible into a set of paths of length $\ge 3$? What if there's one way to decompose the flow into paths of length $\ge 3$, but you can also find some path of length $<3$ in the flow? – D.W. Oct 15 '15 at 18:21
  • I wonder why those who can't solve the problem give a downvote! The original problem says, there are N seats, numbered from 1 through N. N people go to sit on the seats, and they have N tickets, numbered again from 1 through N. The person with ticket 1 comes first, the next would have ticket 2, and so forth. – beginner1010 Oct 16 '15 at 03:55
  • A person with ticket x can sit on one of those seats, whose their numbers are divisible by x. For example, a person with ticket 3 can sit on one of seats 3,6,9, .... People should sit if they can. What is the least number of people, who can sit on seats?

    In my solution: I built a graph, in which a connection between two numbers is established when there is a divisibility between those numbers. Then, I need to run the modified max flow method that I explained.

    – beginner1010 Oct 16 '15 at 03:55
  • Please edit the question to incorporate clarifications or additional information. You should not leave information only in the comments. Comments exist to help you improve your question, and can disappear at any time. We want questions to be self-contained: readers shouldn't have to read the comments to understand your question. If it happens that others have misunderstood the problem statement (I don't know whether that applies here), you might consider what clarifications you can add to your question to ensure that it is sufficiently clear what the problem statement is. – D.W. Oct 16 '15 at 03:58
  • The question is what I asked as Question. It is clear! I left the messages to reply to your question that you asked "What have you considered or tried?". The question is still about the modified max flow method, and I don't believe, probably unlike you, more information is required. – beginner1010 Oct 16 '15 at 04:03
  • 1
    It may be clear to you, but it's not clear to me -- for instance, I still don't see an answer to my questions about what exactly counts as a valid flow, or what you want to have happen if there are multiple ways to decompose a flow into paths. What matters most is not whether it is clear to you (or me); what matters is whether it is sufficiently clear to answerers. It's in your interests to ensure the question is clear to as many people as possible. If you believe it's already clear, that is your call (and something the community is able to vote on). – D.W. Oct 16 '15 at 04:07
  • 1
    Also, please understand that questions of the form "here is my exercise problem, I can't see how to solve it, please solve it for me" are not always well-received on this site. Different folks have different views on this, but here is one: arguably, the purpose of exercises is for you to get practice learning to solve problems, and to help you diagnose gaps in your knowledge; having us solve the exercise for you arguably serves neither of those purposes, and helps neither you nor future visitors. Just letting you know so that you can be prepared for that as a possible reaction. – D.W. Oct 16 '15 at 04:09
  • Thank you for the messages and taking time pursing the question. First, I don't want people to solve my questions! I reached a solution in which the max flow method must be modified to solve this riddle. I have thought many days to find a solution for the max flow method although I have not been successful. I didn't want to give the original problem for the reason you mentioned; indeed, you forced me to write the original one because I feared that I might be faced with an influx of irrational, biased downvotes since your comment, you as a very experienced user, has remained unanswered. – beginner1010 Oct 16 '15 at 04:19
  • I wasn't asking for the original problem. I was asking for you to be more precise about what counts as an allowable flow, as there is some ambiguity in the question. It's not clear what it means to ask that the algorithm "ignore such-and-such paths". Suppose that I construct an algorithm that outputs a flow that can be expressed as the union of a set of paths of length $\ge 3$, but it turns out there is a node $v$ such that there is non-zero flow along the edge $\text{source} \to v$ and non-zero flow along $v \to \text{sink}$. Is that flow allowable/valid/legal? I can't tell. – D.W. Oct 16 '15 at 04:38
  • The question has been updated. – beginner1010 Oct 16 '15 at 04:55

1 Answers1

1

Let $G=(V,E)$ be some directed graph where every node $v_i$, except for the source $s$ and sink $t$, has an in-edge $(s,v_i)$ and an out-edge $(v_i,t)$.

To compute the desired flow, we can reduce the problem to a new directed graph $G'=(V',E')$, where every node of the original Graph, except for $s$ and $t$, is replaced by two new nodes $v_i'$ and $v_i''$. The source is now connected to $v_i'$ and the sink to $v_i''$. Thus, we have new edges $(s,v_i')$ and $(v_i'',t)$. Furthermore, we connect every $v_i''$ with the corresponding $v_i'$ via an edge $(v_i'',v_i')$ of very high capacity. Finally, we add an edge $(v_i',v_j'')$ for every edge $(v_i,v_j)$ of the original graph. The capacity of every edge in $G'$ is equal to its counterpart in $G$, except for the edges $(v_i'',v_i')$, wich correspond to nodes in $G$ and therefore have arbitrary high capacity.

Note that flow that enters $v_i'$ via the source can not directly escape to the sink but must traverse an edge $(v_i',v_j'')$ to another vertex $v_j''$ first. From $v_j''$ the flow can either go to the sink, or continue onwards via $v_j'$. Thus, by computing a maximum flow in $G'$ we obtain a solution for $G$ where all flow that leaves the sink must traverse at least three edges before it reaches the sink.

Dennis Kraft
  • 618
  • 5
  • 12
  • Interesting! but it does not give the correct max flow. Imagine the capacity of all source -> node and node -> sink edges are 1.It means each node can be used once at most; however, in your solution, different flows can be found in which one node has been used more than once. – beginner1010 Oct 16 '15 at 01:17
  • What do you mean by a vertex is used at most once? I don't understand your point. Maybe you can give an example. Also, maybe I should clarify that the capacities of the edges in G' correspond to their counterparts in G, except for (v'',v'), which has no corresponding edge in G. – Dennis Kraft Oct 16 '15 at 05:43
  • As I mentioned, some vertices might be used more than once in your solution although since the capacity of all edges is 1, each vertex can be used once at most. I have also implemented your solution that does not work in general. As the graph for which your method gives incorrect answer is fairly large, it is not possible to presenet it here unfortunately. The graph has 17 nodes – beginner1010 Oct 16 '15 at 08:29
  • That dosn't answer my question of what you mean by "use". If you mean that there is flow entering and exiting a vertex via different edges, then the same thing is possible in the original graph. For instance, consider the Graph G = ({s,t,u,v,w,x}, {(u,v),(w,v),(v,x)} U {"source and sink edges"}). A maximum flow that satisfies your additional constraint (which is not clearly stated at all as D.W. pointed out), would be a path s->u->v->t and another path s->w->v->x->t. Note that v was "used" twice in this maximum flow. Please be more specific. Otherwise it is impossible to help. – Dennis Kraft Oct 16 '15 at 08:54
  • Thank you for the message. Actually, I had made a premise mistakenly. I thought if the capacity of $source \to v$ is $1$ we can use vertex $v$ in the maximum flow at most once. However, as you explained it is not correct although, if I am not wrong again, you have solved what the question asks correctly. – beginner1010 Oct 16 '15 at 09:41
  • About what D.W. pointed out, I don't agree with you. People just give upvotes and downvotes because of reputation of a user handle. In the following problem, although what D.W. says is correct in general, his answer doesn't solve the problem. When people watch the responses, say by themselves, oh! he has 30K points so his answer is correct! and might say oh poor beginner1010! with too little reputation; your answer is not reasonable as your point indicate: http://cs.stackexchange.com/questions/48298/algorithm-for-finding-maximum-mutually-coprime-subset-of-a-multiset-of-integers/48304#48304 – beginner1010 Oct 16 '15 at 09:48
  • However, I agree that the the utilization of word "use", which was utilized in a comment under your post, is ambiguous. This occurred due to the premise that I explained in the previous messages, but D.W. complains about lack of details that are irrelevant and unnecessary. – beginner1010 Oct 16 '15 at 09:57
  • Well, first of all I am glad that the problem is solved. However, as I see it, D.W. did not try to answer your question but help you restate the problem in a more precise manner. And he also has a valid point in doing so. For instance, if you consider the graph from the example I gave above, there is another max flow that satisfies your constraint, namely s->u->v->t and s->v->x->t. But we can also express this flow as s->u->v->x->t and s->v->t, which would not satisfy your requirement. Do you see the ambiguity now? – Dennis Kraft Oct 16 '15 at 10:13
  • Thank you for more explanation, I meant his answer in: http://cs.stackexchange.com/questions/48298/algorithm-for-finding-maximum-mutually-coprime-subset-of-a-multiset-of-integers/48304#48304 Yes, it can be expressed as you mentioned. We can enlarge one path and reduce the other to make a contradiction with the requirement. What's the ambiguity? The max flow method would find finally all paths under restraints with the help of your solution. – beginner1010 Oct 16 '15 at 10:53
  • The ambiguity lies in the fact that a certain flow can be decomposed into paths in many different ways and some of these decompositions may meet you requirements and other may not, although they represent the same flow. From your question it is not clear if you want all of the possible decompositions to be paths of length three or if the existence of one such decomposition is enough. Apparently you were looking for the later one. But this was not explicitly stated in the question. – Dennis Kraft Oct 16 '15 at 11:27