public List<WeightedEdge> RunPrim() {
		nodesList = new ArrayList<Integer>(nodes);
		Random rnd = new Random();
		
		// blue edges
		K = new ArrayList<WeightedEdge>();
		U = new ArrayList<Integer>();
		Close = new int[nodes.size()];
		ClosestWeight = new double[nodes.size()];
		
		int node = nodesList.get(rnd.nextInt(nodes.size()));
		// first element in U
		initializeClose(node);
				
		Set<Integer> tempSet = new HashSet<Integer>(U);
		
		while (!tempSet.containsAll(nodes)) {
			
			int maxIdx = selectMaximumFromClosest();
			
			int nodeInsideU = Close[maxIdx];
			
			for (int i = 0; i < edges.size(); i++) {
				WeightedEdge e = edges.get(i);
				if ((e.getN1()==nodeInsideU && e.getN2()==maxIdx) ||
					(e.getN1()==maxIdx && e.getN2()==nodeInsideU)) {
					K.add(e);
					break;
				}
			}
			
			U.add(maxIdx);
			
			update(maxIdx);
			
			tempSet=new HashSet<Integer>(U);
		}
		
		return K;
	}