From: equinox Date: 2008-11-20T22:51:14+09:00 Subject: Re: BFS in ruby from a hash On Nov 20, 12:34 am, Robert Klemme wrote: > On 20.11.2008 04:54, equinox wrote: > > > I want to do a breadth first search on a hash like below: > > >http://pastie.org/319366 > > > can anyone give me some idea where to start as I've never done bfs > > (breadth first search) on hash before. > > http://en.wikipedia.org/wiki/Breadth-first_search#Algorithm_.28inform... > > If you just want to visit all nodes (i.e. not a search) then you need to > remember all visited nodes and not put new nodes into the queue which > you have seen already. > > Kind regards > >         robert Yes I know the algorithm of doing BFS, however I can't see where a hash is a graph structure... How do I visit the child here? Which ones are trees in the same level?