- #1
evinda
Gold Member
MHB
- 3,836
- 0
Hello! (Wave)
Given the following algorithm:
and this definition:
there are the following sentences:
Could you explain me the above sentences? (Thinking)
Given the following algorithm:
Code:
Breadthfirstsearch(G,s)
for each u ∈ V \ {s}
color[u]<-white
d[u]<-oo
p[u]<-Ø
color[s]<-gray
d[s]<-0
p[s]<-Ø
Q<-Ø
Insert(Q,s)
while Q ≠ Ø
u<-Del(Q)
for each v ∈ Adj(u)
if color[v]=white then
color[v]<-gray
d[v]=d[u]+1
p[v]<-u
Insert(Q,v)
color[u]<-black
and this definition:
With $\delta (s,v)$ we symbolize the length of the shortest path from vertex $s$ to vertex $u$.If $v$ is not accessible from $s$,we set $\delta (s,v)=+\infty$.
there are the following sentences:
- For each edge $(u,v) \in E$, $\delta (s,v) \leq \delta (s,u)+1$
$$$$
- At the end of the bread-first search, $d[v] \geq \delta (s,v), \forall v \in V $.
$$$$ - Suppose that during the implementation of the breadth-first-search,the queue $Q$ contains the vertices $v_1,v_2, \dots ,v_r$ ,where $v_1$ is the head of the queue.Then:
$$d[v_r] \leq d[v_1]+1 \ \text{ and } \ d[v_i] \leq d[v_{i+1}],i=1,2, \dots ,r-1$$
Could you explain me the above sentences? (Thinking)