LOL JK the difference is NOTHING.
Multi source BFS is essentially starting BFS from a deeper level of the graph. So essentially instead of starting with root, we start with N-nodes that are all considered to be level 0. and we expand outwards from there.

I’ll write a simple pseudo code of the algorithm to jog our memory, the pitfall to make note of is that since we want to iterate all nodes in the same level, we want to not get them duplicated/circly traversed, we need to mark them when we append them, not when when pop them from the list.
So say I’m at level 0, with 3 nodes, then for each of the neighbor, when i get those neighbor, immediately mark them as visited then push them to the queue, this ensure that in all the neighbors of the 3 level 0 nodes, they will not be re-added if there’s multiple paths to them, they will be marked the first time appended and only added/traversed once.

Code: In the code i’m assuming we’re on a grid matrix with some nodes are wall and not traversable

 
grid = [...] # matrix n * m
visited = set()
startingNodes = [(0,0), (1,2), (2,3)]
queue = deque(startingNodes)
 
while queue:
	node = queue.popleft()
	print(nei)
	for nei in neighbors: # left right up down
		if outOfBound(nei): continue
		if wall(nei): continue # not connected
		if nei in visited: continue
		
		visited.add(nei)
		queue.append(nei)
 
return

What’s this code useful for? I might update this list later

  • Path finding from some destinations to all nodes in a matrix.
    • Ex: you have some “door” in your dungeon and you need to calculate the distance from all other nodes to there (for character movement), this is your guy.

For a specific practice problem, check this one out Lint Code - Walls and Gate , here’s my Solution