educative.io

Educative

The algorithm seems to be wrong

if in testGraph1, you change the order in which the edges are added, the result will be different. for example the following combination provides 8 instead of 7:
List<ArrayList> e = new ArrayList<ArrayList>();
e.add(e5);
e.add(e2);
e.add(e3);
e.add(e4);
e.add(e1);
e.add(e6);