public AdjacencyList getMinBranching(Node root, AdjacencyList list) {
        AdjacencyList reverse = list.getReversedList();
        // remove all edges entering the root
        if (reverse.getAdjacent(root) != null) {
            reverse.getAdjacent(root).clear();
        }
        AdjacencyList outEdges = new AdjacencyList();
        // for each node, select the edge entering it with smallest weight
        for (Node n : reverse.getSourceNodeSet()) {
            List<Edge> inEdges = reverse.getAdjacent(n);
            if (inEdges.isEmpty()) {
                continue;
            }
            Edge min = inEdges.get(0);
            for (Edge e : inEdges) {
                if (e.getWeight() < min.getWeight()) {
                    min = e;
                }
            }
            outEdges.addEdge(min.getTo(), min.getFrom(), min.getBond());
        }

        // detect cycles
        List<List<Node>> cycles = new ArrayList<List<Node>>();
        cycle = new ArrayList<Node>();
        getCycle(root, outEdges);
        cycles.add(cycle);
        for (Node n : outEdges.getSourceNodeSet()) {
            if (!n.isVisited()) {
                cycle = new ArrayList<Node>();
                getCycle(n, outEdges);
                cycles.add(cycle);
            }
        }

        // for each cycle formed, modify the path to merge it into another part of the graph
        AdjacencyList outEdgesReverse = outEdges.getReversedList();

        for (List<Node> x : cycles) {
            if (x.contains(root)) {
                continue;
            }
            mergeCycles(x, list, reverse, outEdges, outEdgesReverse);
        }
        return outEdges;
    }