@SuppressWarnings({ "unchecked"})
	public static void main(String[] args)
	{
		Graph G = null;
		try
		{
			G = new Graph(new In(args[0]));
		}
		catch (Exception e)
		{
			System.err.println(e);
			System.exit(1);
		}

		IConnectedComponents cc = new ConnectedComponents(G);

		int M = cc.componentCount();
		System.out.println(M + " components");

		Collection<Integer>[] components;
		components = (Collection<Integer>[]) new LinkedList[M];
		for (int i = 0; i < M; i++)
			components[i] = new LinkedList<Integer>();

		for (int v = 0; v < G.V(); v++)
			components[cc.id(v)].add(v);

		for (int i = 0; i < M; i++)
		{
			for (int v : components[i])
				System.out.print(v + " ");
			System.out.println();
		}

	}