Name: Score:
22 Multiple choice questions
Term 1 of 22
SCC algorithm time complexity
Use for max flow problems where capacities are always integers
O(n+m)
Uses topological sort (O(n+m)) on the reverse graph
O(mC), Pseudo-polynomial. C=size of max flow. Assumes integer capacities
To find the MST of an undirected graph
Term 2 of 22
When to use Dijkstra's?
Only useful for directed graphs. Use to get a metagraph of connected components. Each
SCC is represented as a single node. The resulting metagraph is always a DAG.
Use for max flow problems where capacities are not necessarily integers. Uses BFS to
find paths to augment. Use if C is unbounded, because runtime is O(nm^2)
Works for both directed and undirected graphs. Must have only non-negative edge
weights.
Use for max flow problems where capacities are always integers
,Term 3 of 22
Dijkstra's runtime?
O((n+m) log n)
log n is from using the min heap (to get the lowest cost weight)
O(n*m)
Remember, this uses a dynamic programming table. Will have found the shortest path
distances after n - 1 iterations. If the distances keep updating, there is a negative weight
cycle.
O(m log n) for both Kruskal's and for Prim's
Returns an n by n matrix of shortest path costs between EVERY pair of vertices.
Term 4 of 22
Edmunds Karp runtime
O(n^3)
visited array.
O(nm^2)
dist array, prev array
Term 5 of 22
When to use Bellman Ford?
Only useful for directed graphs. Use to get a metagraph of connected components. Each
SCC is represented as a single node. The resulting metagraph is always a DAG.
Use for max flow problems where capacities are not necessarily integers. Uses BFS to
find paths to augment. Use if C is unbounded, because runtime is O(nm^2)
Use for max flow problems where capacities are always integers
Use when there is a graph with negative edge weights. Gives us the shortest path from s
to every other vertex v. Slower than Dijkstra's algorithm. Dijkstra's was O((n+m)logn), but
this is O(n*m). Can also be used to detect negative weight cycles IF the cycle is reachable
from sources.
, Term 6 of 22
Complexity to find an MST
O(m log n) for both Kruskal's and for Prim's
Returns an n by n matrix of shortest path costs between EVERY pair of vertices.
O((n+m) log n)
log n is from using the min heap (to get the lowest cost weight)
O(n*m)
Remember, this uses a dynamic programming table. Will have found the shortest path
distances after n - 1 iterations. If the distances keep updating, there is a negative weight
cycle.
Term 7 of 22
How can we construct the minimum st cut from Ford Fulkerson?
Use for max flow problems where capacities are always integers
Take a max flow from Ford Fulkerson, f. In the residual network of G, using f, we know
that there is no path from s to t. We can set L to be the vertices reachable from s in the
residual network and R to be the vertices reachable from t in the residual network.
Use for max flow problems where capacities are not necessarily integers. Uses BFS to
find paths to augment. Use if C is unbounded, because runtime is O(nm^2)
An st cut is a cut that partitions the vertices of a graph into one set containing the source
vertex s and the other containing t. The st cut also specifies the edges that have one
endpoint in the set containing s and the other endpoint in the set containing t. The
weight/capacity of an st cut is the sum of the weights of the edges that cross the cut. The
minimum capacity st cut is also known as the maximum flow of the graph
22 Multiple choice questions
Term 1 of 22
SCC algorithm time complexity
Use for max flow problems where capacities are always integers
O(n+m)
Uses topological sort (O(n+m)) on the reverse graph
O(mC), Pseudo-polynomial. C=size of max flow. Assumes integer capacities
To find the MST of an undirected graph
Term 2 of 22
When to use Dijkstra's?
Only useful for directed graphs. Use to get a metagraph of connected components. Each
SCC is represented as a single node. The resulting metagraph is always a DAG.
Use for max flow problems where capacities are not necessarily integers. Uses BFS to
find paths to augment. Use if C is unbounded, because runtime is O(nm^2)
Works for both directed and undirected graphs. Must have only non-negative edge
weights.
Use for max flow problems where capacities are always integers
,Term 3 of 22
Dijkstra's runtime?
O((n+m) log n)
log n is from using the min heap (to get the lowest cost weight)
O(n*m)
Remember, this uses a dynamic programming table. Will have found the shortest path
distances after n - 1 iterations. If the distances keep updating, there is a negative weight
cycle.
O(m log n) for both Kruskal's and for Prim's
Returns an n by n matrix of shortest path costs between EVERY pair of vertices.
Term 4 of 22
Edmunds Karp runtime
O(n^3)
visited array.
O(nm^2)
dist array, prev array
Term 5 of 22
When to use Bellman Ford?
Only useful for directed graphs. Use to get a metagraph of connected components. Each
SCC is represented as a single node. The resulting metagraph is always a DAG.
Use for max flow problems where capacities are not necessarily integers. Uses BFS to
find paths to augment. Use if C is unbounded, because runtime is O(nm^2)
Use for max flow problems where capacities are always integers
Use when there is a graph with negative edge weights. Gives us the shortest path from s
to every other vertex v. Slower than Dijkstra's algorithm. Dijkstra's was O((n+m)logn), but
this is O(n*m). Can also be used to detect negative weight cycles IF the cycle is reachable
from sources.
, Term 6 of 22
Complexity to find an MST
O(m log n) for both Kruskal's and for Prim's
Returns an n by n matrix of shortest path costs between EVERY pair of vertices.
O((n+m) log n)
log n is from using the min heap (to get the lowest cost weight)
O(n*m)
Remember, this uses a dynamic programming table. Will have found the shortest path
distances after n - 1 iterations. If the distances keep updating, there is a negative weight
cycle.
Term 7 of 22
How can we construct the minimum st cut from Ford Fulkerson?
Use for max flow problems where capacities are always integers
Take a max flow from Ford Fulkerson, f. In the residual network of G, using f, we know
that there is no path from s to t. We can set L to be the vertices reachable from s in the
residual network and R to be the vertices reachable from t in the residual network.
Use for max flow problems where capacities are not necessarily integers. Uses BFS to
find paths to augment. Use if C is unbounded, because runtime is O(nm^2)
An st cut is a cut that partitions the vertices of a graph into one set containing the source
vertex s and the other containing t. The st cut also specifies the edges that have one
endpoint in the set containing s and the other endpoint in the set containing t. The
weight/capacity of an st cut is the sum of the weights of the edges that cross the cut. The
minimum capacity st cut is also known as the maximum flow of the graph