You are on page 1of 1

Breadth-first Search in Digraphs

denotes a tree edge. Oper- Cur-


Queue
ation rent
enq A A
The two integers above each vertex are deq A A
i) A sequence number k. The vertex is the enq B A B
kth vertex enqueued, and also the kth enq F A BF
vertex dequeued and processed. deq B B F
enq D B FD
ii) The “distance” from the starting vertex enq M B FDM
(in our example, A). Here distance deq F F DM
simply means the minimal number of enq C F DMC
edges on a path from the starting vertex. deq D D MC
enq N D MCN
deq M M CN
4,2 7,3 enq E M CNE
2,1
N enq G M CNEG
B D 13,4 enq H M CNEGH
1,0 enq I M CNEGHI
O
A enq Q M CNEGHIQ
3,1 6,2 Q deq C C NEGHIQ
F C 12,3 deq N N EGHIQ
enq O N EGHIQO
5,2 P deq E E GHIQO
8,3 M 11,3 deq G G HIQO
16,4
E I enq L G HIQOL
10,3 deq H H IQOL
deq I I QOL
H 14,4 enq K I QOLK
deq Q Q OLK
G L
enq P Q OLKP
9,3 deq O O LKP
17,5 deq L L KP
K
deq K K P
J 15,4 enq J J PJ
deq P P J
deq J J

You might also like