Distributed BFS
Required Readings
Optional
Summary
Graphs and Adjacency Matrices
To turn a graph into an adjacency matrix:
- Give each vertex an integer label
- Create a matrix to represent the graph
- For any edge going from i to j,
A[i][j] = true/1
Matrix for an undirected graph is symmetric
For n vertices and m edges, the array will be of size nxn with 2m non-zeroes
Matrix based BFS
Start with some starting node S, an add all its neighbors to frontier 1. Iterate through frontier 1 and add all of its unvisited neighbors to frontier 2, etc.
For any unvisited node i, there is a given frontier L, if there are any edges from frontier to i, we should update i’s distance.
For any frontier (vector), does i have any 1’s in the corresponding locations, if so, we can update another vector to record this.
This is just a boolean matrix-vector product
for-all ui = 1 and di = inf do
di <- l + 1
fi <- 1
1D Distributed BFS
- Partition columns of A and entries of U by p processes
- Compute
- Update local distances
- Identify local vertices of the next frontier
- All-to-all, exchange frontier
2D Distributed BFS