How would residual capacities translate into an adjacency matrix from computing max flow?

196 Views Asked by At

I was wondering how would the forward and backward edges of residual capacities from the ford-fulkerson algorithm would translate in matrix? Would the upper triangular matrix be the forward edges and lower part be the backward edges?

1

There are 1 best solutions below

0
On

There are several different ways of encoding a graph as a matrix, so I don't think we could speak specifically of "the" way of doing this.

The most common way to encode a graph with weights / capacities on its edges as a matrix is as an adjacency matrix. To form it, number the nodes in the graph 1, 2, 3, ..., n. Then the entry at row i, column j corresponds to the capacity on the edge going from node i to node j. If the capacity is positive, then that entry would be positive. If the it's a residual edge, the value would be negative. And if there isn't an edge from the first node to the second, or if the edge is saturated, the value in the matrix would be zero.