Suppose I have List[Node] — a list of nodes and a function isConnected(n1:Node, n2:Node):Boolean. Now I would like to create a map Map[Node, List[Node]], which maps every node to the list of its neighbours.
I am trying to figure out how to use groupBy for that. Does it make sense? How would you create the neighbours map in idiomatic Scala?
How about something like this?