public boolean analyze( Collection<DependencyNode<T>> nodeCollection, T ... emptyArray )
	{
		final int N = nodeCollection.size();

		nodes = nodeCollection.toArray( new DependencyNode[N] );

		cycle = new DependencyNode[N];
		cycleSize = 0;

		ordered = Arrays.copyOf( emptyArray, N );
		orderedNodes = new DependencyNode[N];
		orderedSize = 0;

		maximumDepth = 0;

		valid = true;

		// Initialize the nodes which have no dependencies. 
		for (int i = 0; i < N; i++)
		{
			DependencyNode<T> dn = nodes[i];

			if (dn.hasDependencies())
			{
				dn.setDepth( -1 );
				cycle[cycleSize++] = dn;
			}
			else
			{
				addOrdered( 0, dn );
			}
		}
		
		// If all nodes have dependencies, there definitely is a cycle involving
		// all nodes.
		if (orderedSize == 0)
		{
			return ( valid = false );
		}

		// While not all nodes have been placed in the ordered array.
		while (orderedSize < N)
		{
			int newlyCycled = 0;

			// Determine for each node whether all of it's dependencies have
			// been placed on the tree, if so place it on the tree, otherwise
			// keep it on the cycle array.
			for (int i = 0; i < cycleSize; i++)
			{
				DependencyNode<T> dn = cycle[i];

				int min = N;
				int max = -1;

				for (DependencyNode<T> dependency : dn.getDependencies())
				{
					min = Math.min( min, dependency.getDepth() );
					max = Math.max( max, dependency.getDepth() );
				}

				// If all dependencies have been placed on the tree, add this
				// node to the tree and mark it's depth and index.
				if (min != -1)
				{
					addOrdered( max + 1, dn );

					maximumDepth = Math.max( maximumDepth, dn.getDepth() );
				}
				// If there was a dependency not yet placed on the tree, 
				// keep it on the cycle array.
				else
				{
					cycle[newlyCycled++] = dn;
				}
			}

			// If no nodes have been added to ordered (or taken from cycle)
			// there is a circular dependency that exists in cycle.
			if (newlyCycled == cycleSize)
			{
				return ( valid = false );
			}

			cycleSize = newlyCycled;
		}

		return ( valid = true );
	}