public void unionCommunities()
	{
		for (int i = 0; i < communities.size(); i++) 
		{
			Community current = communities.get(i);
			for (int j = 0; j < current.size(); j++) 
			{
				int node = current.get(j);
				for (int k = 0; k < communities.size(); k++) {
					if(communities.get(k).nodeExistsInCommunity(node) && i != k)
					{
						Community com = communities.get(k);
						while(!com.isEmpty())
						{
							current.addToCommunity(com.remove(0));
						}
					}
				}
			}
		}
		
		//now loop through the communities and remove all of the empty ones
		
		ArrayList<Integer> emptyCommunities = new ArrayList<>();
		for (int i = 0; i < communities.size(); i++) 
		{
			if (communities.get(i).isEmpty())
			{
				emptyCommunities.add(i);
			}
		}
		
		int changeFactor = 0;	//when we remove, all other indices shift left by 1. need to take this into account
		for (int i = 0; i < emptyCommunities.size(); i++) 
		{
			int index = emptyCommunities.get(i) - changeFactor;
			communities.remove(index);
			changeFactor++;
		}
	}