public void setWeights(Node root) {
        System.out.println("Visited nodes " + root.name);
        List<Edge> edges = AdjacencyList.getAdjacent(root);
        for (Edge edge : edges) {
            if (result[edge.getTo().name] == -1 || result[edge.getTo().name] > (edge.weight + result[root.name]))
                result[edge.getTo().name] = edge.weight + result[root.name];
        }
        visited[root.name] = 1;
        int res = getMinimum();
        if (res == -1) return;
        setWeights(new Node(res));
    }