• Connected method:direct connections instead of all

Question related to mission Friends

When I started to solve the last task (connected method) I thought that this method has to return the set of ALL connections of a name given. For example, if we have ( {a,b}, {b,c}, {c,d}, {e,f}), then CONNECTED(a) should return (b,c,d) - not only the direct connection (b).

But at last I understood that the task was much simplier - the method should return only the DIRECT connections.

Nevertheless, it's interesting, how to solve more complex task - to return all the connections of the given element (friends of friends of friends ..etc)

Did anybody try to create that kind of algorithm?