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
		Set<Node> nodes = list.getSourceNodeSet();
		//check every node 
		Iterator<Node> it = nodes.iterator();
		while(it.hasNext()){
			Node current = it.next();
			//if it is not the root, select the smallest entering edge 
			//put the smallest entering edge into the new adjacent graph
			if(!current.equals(root)){
				ArrayList<Edge> enteringEdges = list.getSortedEnteringEdge(current);
				if(enteringEdges.size() == 0) continue;
				Edge smallestOne = enteringEdges.get(0);
				outEdges.addEdge(smallestOne.from, smallestOne.to, smallestOne.weight);
			}
		}

		// detect cycles
		ArrayList<ArrayList<Node>> cycles = new ArrayList<ArrayList<Node>>();
		cycle = new ArrayList<Node>();
		getCycle(root, outEdges);
		cycles.add(cycle);
		for(Node n : outEdges.getSourceNodeSet()){
			if(!n.visited){
				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(ArrayList<Node> x : cycles){
			if(x.contains(root)) continue;
			mergeCycles(x, list, reverse, outEdges, outEdgesReverse);
		}
		return outEdges;
	}