def depth_first_search(v)
raise ArgumentError, "No such vertex" if v < 0 or
vertices <= v
is_visited = []
visit = lambda do |v|
each_edge(v) do |v,w|
next if is_visited[w]
yield v,w
is_visited[w] = true
visit.call(w)
end end
yield -1,v
is_visited[v] = true
visit.call(v)
end