Why is ford-fulkerson so ubiquitous? - algorithm

When looking at max flow solutions, ford-fulkerson seems to be ubiquitous in that it is the algorithm most people implement to solve this problem. However there are many more algorithms that can solve the problems and at a significantly better time complexity. So why is ford-fulkerson still so widely used then?

Ford–Fulkerson is the simplest algorithm that embodies the key idea that a flow is maximum if and only if it has no augmenting path. This makes it useful for teaching.
Since F–F doesn't specify how to find an augmenting path, it's more of a framework than an algorithm. Edmonds–Karp is an instantiation of F–F that bounds the number of augmenting paths that must be found. Dinic's algorithm improves on Edmonds–Karp by keeping a data structure that allows it to find augmenting paths more efficiently. (Off the beaten path a bit, the O(n log n)-time algorithm for s-t flow in planar networks due to Borradaile and Klein is also an F–F instantiation.)
The push-relabel algorithms take the idea behind Dinic's algorithm one step further, but they break out of the F–F mold in using preflows, not flows (preflows allow more flow to enter a vertex than leaves, but not vice versa). Historically they followed Dinic's algorithm and make more intuitive sense as a reaction to Dinic.
The other algorithms on that list are complicated and not suitable for undergraduate instruction, which explains the lack of tutorial material.

Ford-Fulkerson algorithm gives the fundamental paradigm to solve a maximum flow problem. Suppose a graph, consisting of Vs and Es, has a source and sink defined. Along with this there is a capacity defined for each E. The ford fulkerson algorithm directs us to find an augmenting path (a path whose capacity has not reached its limit), and to send as much flow as we can through that path, and accordingly update the capacities.
Ford-Fulkerson algorithm however, doesn't exactly specify how to find these augmenting paths. This is the primary research that is done today in this field. The classic ford fulkerson with simple graph searching algorithms give the time complexity of O(n^2). There have been several attempts from Dinitz, to many other CS experts such as Spielman and Teng, who have managed to bring the complexity down to a level of O(n^1.43). The primary challenge these days is to bring the time to nearly linear.

Related

Max flow in unweighted graph

Max flow problem is usually solved by edmond-karp algorithm, which is building residual graph, and using BFS to find augmenting paths.
But usually max flow problem is defined for weighted graph. For unweighted graph, we can simply treat the weight of each edge as 1, but I wonder if there is any simpler algorithm to solve the unweighted version.
Usually people refer to edge "capacities" when talking about flow problems, and "weights/costs" when talking about distance related problems. This causes less confusion.
To rephrase your question, does there exist a simpler algorithm for the max flow problem when every edge has the capacity of 1?
It really depends on what you mean by "simpler", but you can use Ford-Fulkerson algorithm to solve this special case in O(VE) time bound, which is much faster than solving it with the aforementioned Edmonds-Karp algorithm with the time bound of O(VE^2).

Graph search algorithm where edges can be blocked by obstacles

I want to find a low-cost path between two vertices on a directed graph where the cost of each edge is the same. Ease of implementing the algorithm and performance time are very important, so I am willing to sacrifice an optimal solution for one that is near-optimal, if the algorithm is simpler and quicker.
An edge can be blocked by an obstacle. The probability that an edge is blocked is known beforehand. Blockages are independent of each other. An edge is found to be unblocked or blocked when the vertex at the head of the edge is reached.
My problem is similar to the Canadian Traveller Problem, but my understanding is that solutions for stochastic programming problems are relatively difficult to implement, and the time taken to find an optimal policy can be relatively high.
At the moment, I am thinking of converting the problem into a deterministic one so that it can be solved using a search algorithm like A*. Is this a good approach, and if so, how can I do this?
This problem is a partially observable Markov decision process (POMDP). POMDPs can be solved deterministically, but usually use a randomized algorithm to find an approximately-optimal solution. Finding the true optimum policy does not have a polynomial time solution, and even approximate solutions can be slow. On the upside, once you've found the policy, following it is fast.
Some of the available solvers:
ZMDP
Symbolic Perseus
APPL
pomdp-solve
SPUDD

Heuristic and A* algorithm

I was reading about dijkstra algorithm and A* star algorithm. I know that the difference is the heuristic used. But what is a heuristic and how this influence the algorithms? Heuristic is just an way to measure the distance? But dijkstra considers the distance too? Sorry, but my question is about heuristic and what it means and why to use them... (I had read about it, but don't understant)
Other question: When should be used each one?
Thank you
In this context, a heuristic is a way of providing the algorithm with some form of extra evaluative information, so that the algorithm can find a 'good enough' solution, without exhaustively searching every possible solution.
Dijkstra's Algorithm does not use a heuristic. It expands outwards from the start node, and examines every node in the graph in order to find the shortest path. While this is accurate, it can be computationally expensive.
By comparison, the A* algorithm uses a distance + cost heuristic, to guide the algorithm in its choice of the next node to explore. This means that the algorithm finds a possible search solution without examining every node on the graph. It is therefore much cheaper to run, but at a loss of complete accuracy. It works because the result is usually close enough to the optimal solution, and is found cheaper than an exhaustive search of the entire graph.
As to when you should use each, it really depends on the application. However, using the A* algorithm requires an admissible heuristic, so this may not be applicable in situations where such information is unavailable to the algorithm.
A heuristic basically means an idea or an intuition! Any strategy that you use to solve a hard problem is a heuristic! In some fields (like combinatorial problems) it refers to the strategy that can help you solve a NP hard problem suboptimally within a polynomial time.
Dijkstra solves the single-source routing problem, i.e. it gives you the cost of going froma single point to any other point in the space.
A* solves a single-source single-target problem. It gives you a minimum distance path from a given point to another given point.
A* is usually faster than Dijkstra provided you give it an admissible heuristic, this is, an estimate of the distance to the goal, that never overestimates said distance. Contrary to a previous answer given here, if the heuristic used is admissible, A* is complete and will give you the optimal answer.

search of the K-first short paths algorithm

I have found many algorithms and approaches that talk about finding the shortest path or the best/optimal solution to a problem. However, what I want to do is an algorithm that finds the first K-shortest paths from one point to another. The problem I'm facing is more like searching through a tree, when in each step you take there are multiple options each one with its weight. What kinds of algorithms are used to face this kind of problems?
There is the 2006 paper by Jose Santos
comparing three different K-shortest path finding algorithms.
Yen's algorithm implementation:
http://code.google.com/p/k-shortest-paths/
Easier algorithm & discussion:
Suggestions for KSPA on undirected graph
EDIT: apparently I clicked on a link, because I thought I was answering to a new question; ignore this if - as is very likely - this question isn't important to you anymore.
Given the restricted version of the problem you're dealing with, this becomes a lot simpler to implement. The most important thing to notice is that in trees, shortest paths are the only paths between two nodes. So what you do is solve all pairs shortest paths, which is O(n²) in trees by doing n BFS traversals, and then you get the k minimal values. This probably can be optimized in some way, but the naive approach to do that is sort the O(n²) distances in O(n² log n) time and take the k smallest values; with some book keeping, you can keep track of which distance corresponds to which path without time complexity overhead. This will give you better complexity than using a KSPA algorithm for O(n²) possible s-t-pairs.
If what you actually meant is fixing a source and get the k nodes with the smallest distance from that source, one BFS will do. In case you meant fixing both source and target, one BFS is enough as well.
I don't see how you can use the fact that all edges going from a node to the nodes in the level below have the same weight without knowing more about the structure of the tree.

Algorithm: shortest path between all points

Suppose I have 10 points. I know the distance between each point.
I need to find the shortest possible route passing through all points.
I have tried a couple of algorithms (Dijkstra, Floyd Warshall,...) and they all give me the shortest path between start and end, but they don't make a route with all points on it.
Permutations work fine, but they are too resource-expensive.
What algorithms can you advise me to look into for this problem? Or is there a documented way to do this with the above-mentioned algorithms?
Have a look at travelling salesman problem.
You may want to look into some of the heuristic solutions. They may not be able to give you 100% exact results, but often they can come up with good enough solutions (2 to 3 % away from optimal solutions) in a reasonable amount of time.
This is obviously Travelling Salesman problem. Specifically for N=10, you can either try the O(N!) naive algorithm, or using Dynamic Programming, you can reduce this to O(n^2 2^n), by trading space.
Beyond that, since this is an NP-hard problem, you can only hope for an approximation or heuristic, given the usual caveats.
As others have mentioned, this is an instance of the TSP. I think Concord, developed at Georgia Tech is the current state-of-the-art solver. It can handle upwards of 10,000 points within a few seconds. It also has an API that's easy to work with.
I think this is what you're looking for, actually:
Floyd Warshall
In computer science, the Floyd–Warshall algorithm (sometimes known as
the WFI Algorithm[clarification needed], Roy–Floyd algorithm or just
Floyd's algorithm) is a graph analysis algorithm for finding shortest
paths in a weighted graph (with positive or negative edge weights). A
single execution of the algorithm will find the lengths (summed
weights) of the shortest paths between all pairs of vertices though it
does not return details of the paths themselves
In the "Path reconstruction" subsection it explains the data structure you'll need to store the "paths" (actually you just store the next node to go to and then trivially reconstruct whichever path is required as needed).

Resources