def breadth_first_search(v)
raise ArgumentError, "No such vertex" if v < 0 or
vertices <= v
queue = LinkedQueue.new
is_visited = []
queue.enter(Edge.new(-1,v))
while !queue.empty? do
edge = queue.leave
next if is_visited[edge.w]
yield edge.v,edge.w
is_visited[edge.w] = true
each_edge(edge.w) do |w,x|
queue.enter(Edge.new(w,x)) if !is_visited[x]
end
end end