Max flow algorithm inputs and outputs
Inputs
(this set of inputs is known as a flow network)
Max flow algorithm assumptions
Build a Residual Network inputs and outputs
Build a Residual Network runtime
O(n + m) but we assumes G is a connected graph and so m >= n-1 and so O(m)
Ford-Fulkerson assumptions / implementation
Ford-Fulkerson runtime
Edmonds-Karp difference from Ford-Fulkerson
Edmonds-Karp runtime
O(nm^2)
Breadth First Search (BFS) Inputs, Outputs, and Runtime
Runtime:
O(n+m)
When should you use BFS?
Use for unweighted single source shortest path problems.
The BFS function outputs a distance-value for each edge. What does this represent?
d[u] gives the distance from u to the start vertex. This is the number of edges. It is NOT the sum of weights (in the case of a weighted graph). BFS does NOT consider weights.
Dijkstra’s Algorithm Inputs, Outputs, and Runtime
Depth First Search (DFS) Inputs, Outputs, and Runtime
Runtime:
O(n+m)
When is the ccnum[z] the strongly connected component number for z?
**Only relevant for directed graphs.
1) you have to run DFS on a reverse of the directed graph.
2) Then, run DFS, starting with the highest post order number from 1.
In this case, the ccnum is also the topological sort order in reverse.
Strongly Connected Components (SCC) algorithm inputs, outputs
Strongly Connected Components (SCC) runtime
O(n+m)
How do you find the SCC of a vertex in a directed graph after running the SCC algorithm on it?
Use the ccnum value for a given vertex that the SCC algorithm returns. I.e. use ccnum[v] for v in the original graph’s vertices to find the SCC of v.
2SAT algorithm inputs, outputs, and runtime
Runtime:
O(n+m) where n is the number of variables and m is the number of clauses.
Conjunctive normal form
*Note: xor = (x xor y) = (x or y) and (~x or ~y)
How many literals are associated with n variables (i.e. [v1, v2, … , vn] used in 2SAT?
Each variable has 2 literals: v1 and ~v1 (~ = not). So n variables is associated with 2n literals.
Is 2SAT NP complete?
No, kSAT for k>2 is NP complete. 2SAT is polynomial.
Kruskal’s MST algorithm inputs, outputs, and runtime
Prim’s inputs, outputs, and runtime
True or false? In a DAG, every edge leads to a vertex with a lower post-order number.
True.