public ArrayList<AdjacencyMatrix> createCommunitiesFromSolutionArray() 
	{
		ArrayList<AdjacencyMatrix> matrices = new ArrayList<>();
		int[] solCopy = new int[size];
		System.arraycopy(solution, 0, solCopy, 0, size);
		Community newCommunity = new Community();
		for(int j = 0; j < size; j++)
		{
			if(solCopy[j]!= -1)
				addToCommunity(ids[j], solCopy[j], newCommunity);		
			int index = solCopy[j];
			solCopy[j] = -1;
			if(index!= -1)
			{
				while(solCopy[index] != -1)
				{					
					addToCommunity(index, solCopy[index], newCommunity);
					int old = index;
					index = solCopy[index];
					solCopy[old] = -1;
				}
				if(!newCommunity.isEmpty())
				{
					communities.add(newCommunity);
					newCommunity = new Community();
				}
			}
		}
		matrices = generateMatrix();
		return matrices;
	}