BFS的基本算法:
set start vertex to visited
load it into queue
while queue not empty
for each edge incident to vertex
if its not visited
load into queue
mark vertex
所以我认为时间复杂度是:
v1 + (incident edges) + v2 + (incident edges) + .... + vn + (incident edges)
v
顶点1
在哪里n
首先,我说的对吗?其次,这是怎么回事O(N + E)
,以及为什么会非常好的直觉。谢谢