Graphs and Network Flow Flashcards
What are the generic loop invariants used for searching a graph starting from some node s
Generic loop invariants:
Nodes are considered to be not found, found, not handled, handled
If Found:
If Handled:
if node v is found, we can trace a path from s to the node, can be traced backwards.
v, π(v), π(π(v)), π(π(π(v))), . . . , s.
If node v is handled, all neighbours have been found.
Extra LI for BFS
Nodes have been found in order of their distance from s.
Extra LI for DFS
Nodes in the stack form a path starting at s going to the current node u being considered
Recursive DFS pre + post cons
Pre: A directed or undirected graph is given, some nodes marked found and some node s’ specified
Post: Every node reachable from s’ is found
Extra LI for Dijkstra’s shortest-weighted paths alg
Extra LI are
- Handled: For each handled node v, the values of d(v) and pi(v) give the shortest length and path from s. (Path only contains handled nodes).
- Found: For each unhandled node v, the values of d( v) and pi(v) give the shortest length and path from s.
Visit any number of handled nodes starting from s, then follow one last node that may or not be handled.
What data structure does Dijkstra’s alg use?
Priority Queue
Steps for Network flow Diagram
Given flow - > Augmenting Graph -> Augmenting path - > New flow
Repeat until augmenting graph no longer has a augmenting path
How to make cut
Cut such that flow out of ‘s’ node = flow into cut ‘u’.
How do you get New flow values?
On the augmenting graph path, find the bottle neck ‘w’ value. Add/subtract if passing through or backward on each node on the path.
Capacity of cut = ?
= Capacity of edges crossing from U to V.
Conclusion to network flow solution
All edges across the cut are at capacity in flow. Any edges going from V to U have no flow in them.
Hence, the flow across the cut equals flow out of s in the final Flow equals capacity of the cut.
Rate of final flow = #
Flow witness statements
The flow witnesses the fact that a flow with rate 16 is obtainable.
The cut witnesses the fact that a flow can be no bigger than 16
Hence a max flow of 16 is optimal.