educative.io

Educative

Question about the data structure used to generate the solution:

The graph used in the solution contains a List of edges. But the edges are only listed one way ex.

Edge(wt: 1, src: 0, dest: 1)

Since this is an undirected graph, don’t we also need to be able to query the edge in the opposite direction. Ex. Edge(wt: 1, src: 1, dest: 0)

ex. 0 -> 1 && 1 <- 0

This solution doesn’t appear very robust. If you adjust the node that it starts on, everything breaks. Also, if you adjust the ordering of source & dest nodes in the graph construction everything breaks. I’m not sure if you can trust this solution on things other then the inputs.