src/main/java/com/mxgraph/layout/hierarchical/mxHierarchicalLayout.java
protected void traverse(Object vertex, boolean directed, Object edge,
			Set<Object> allVertices, Set<Object> currentComp,
			List<Set<Object>> hierarchyVertices, Set<Object> filledVertexSet)
	{
		mxGraphView view = graph.getView();
		mxIGraphModel model = graph.getModel();

		if (vertex != null && allVertices != null)
		{
			// Has this vertex been seen before in any traversal
			// And if the filled vertex set is populated, only 
			// process vertices in that it contains
			if (!allVertices.contains(vertex)
					&& (filledVertexSet == null ? true : filledVertexSet
							.contains(vertex)))
			{
				currentComp.add(vertex);
				allVertices.add(vertex);

				if (filledVertexSet != null)
				{
					filledVertexSet.remove(vertex);
				}

				int edgeCount = model.getEdgeCount(vertex);

				if (edgeCount > 0)
				{
					for (int i = 0; i < edgeCount; i++)
					{
						Object e = model.getEdgeAt(vertex, i);
						boolean isSource = view.getVisibleTerminal(e, true) == vertex;

						if (!directed || isSource)
						{
							Object next = view.getVisibleTerminal(e, !isSource);
							traverse(next, directed, e, allVertices,
									currentComp, hierarchyVertices,
									filledVertexSet);
						}
					}
				}
			}
			else
			{
				if (!currentComp.contains(vertex))
				{
					// We've seen this vertex before, but not in the current component
					// This component and the one it's in need to be merged
					Set<Object> matchComp = null;

					for (Set<Object> comp : hierarchyVertices)
					{
						if (comp.contains(vertex))
						{
							currentComp.addAll(comp);
							matchComp = comp;
							break;
						}
					}

					if (matchComp != null)
					{
						hierarchyVertices.remove(matchComp);
					}
				}
			}
		}
	}
/**
	 * Traverses the (directed) graph invoking the given function for each
	 * visited vertex and edge. The function is invoked with the current vertex
	 * and the incoming edge as a parameter. This implementation makes sure
	 * each vertex is only visited once. The function may return false if the
	 * traversal should stop at the given vertex.
	 * 
	 * @param vertex <mxCell> that represents the vertex where the traversal starts.
	 * @param directed Optional boolean indicating if edges should only be traversed
	 * from source to target. Default is true.
	 * @param edge Optional <mxCell> that represents the incoming edge. This is
	 * null for the first step of the traversal.
	 * @param allVertices Array of cell paths for the visited cells.
	 */
Traverses the (directed) graph invoking the given function for each
visited vertex and edge. The function is invoked with the current vertex
and the incoming edge as a parameter. This implementation makes sure
each vertex is only visited once. The function may return false if the
traversal should stop at the given vertex.

@param vertex  that represents the vertex where the traversal starts.
@param directed Optional boolean indicating if edges should only be traversed
from source to target. Default is true.
@param edge Optional  that represents the incoming edge. This is
null for the first step of the traversal.
@param allVertices Array of cell paths for the visited cells.
Traverses the ( directed ) graph invoking the given function for each visited vertex and edge . The function is invoked with the current vertex and the incoming edge as a parameter . This implementation makes sure each vertex is only visited once . The function may return false if the traversal should stop at the given vertex . @param vertex that represents the vertex where the traversal starts . @param directed Optional boolean indicating if edges should only be traversed from source to target . Default is true . @param edge Optional that represents the incoming edge . This is null for the first step of the traversal . @param allVertices Array of cell paths for the visited cells .
protected void traverse(Object vertex, boolean directed, Object edge,
			Set<Object> allVertices, Set<Object> currentComp,
			List<Set<Object>> hierarchyVertices, Set<Object> filledVertexSet)
	{
		mxGraphView view = graph.getView();
		mxIGraphModel model = graph.getModel();
		if (vertex != null && allVertices != null)
		{
			if (!allVertices.contains(vertex)
					&& (filledVertexSet == null ? true : filledVertexSet
							.contains(vertex)))
			{
				currentComp.add(vertex);
				allVertices.add(vertex);
				if (filledVertexSet != null)
				{
					filledVertexSet.remove(vertex);
				}
				int edgeCount = model.getEdgeCount(vertex);
				if (edgeCount > 0)
				{
					for (int i = 0; i < edgeCount; i++)
					{
						Object e = model.getEdgeAt(vertex, i);
						boolean isSource = view.getVisibleTerminal(e, true) == vertex;
						if (!directed || isSource)
						{
							Object next = view.getVisibleTerminal(e, !isSource);
							traverse(next, directed, e, allVertices,
									currentComp, hierarchyVertices,
									filledVertexSet);
						}
					}
				}
			}
			else
			{
				if (!currentComp.contains(vertex))
				{
					Set<Object> matchComp = null;
					for (Set<Object> comp : hierarchyVertices)
					{
						if (comp.contains(vertex))
						{
							currentComp.addAll(comp);
							matchComp = comp;
							break;
						}
					}
					if (matchComp != null)
					{
						hierarchyVertices.remove(matchComp);
					}
				}
			}
		}
	}
protected void traverse ( Object vertex , boolean directed , Object edge , Set < Object > allVertices , Set < Object > currentComp , List < Set < Object > > hierarchyVertices , Set < Object > filledVertexSet ) { mxGraphView view = graph . getView ( ) ; mxIGraphModel model = graph . getModel ( ) ; if ( vertex != null && allVertices != null ) { if ( ! allVertices . contains ( vertex ) && ( filledVertexSet == null ? true : filledVertexSet . contains ( vertex ) ) ) { currentComp . add ( vertex ) ; allVertices . add ( vertex ) ; if ( filledVertexSet != null ) { filledVertexSet . remove ( vertex ) ; } int edgeCount = model . getEdgeCount ( vertex ) ; if ( edgeCount > 0 ) { for ( int i = 0 ; i < edgeCount ; i ++ ) { Object e = model . getEdgeAt ( vertex , i ) ; boolean isSource = view . getVisibleTerminal ( e , true ) == vertex ; if ( ! directed || isSource ) { Object next = view . getVisibleTerminal ( e , ! isSource ) ; traverse ( next , directed , e , allVertices , currentComp , hierarchyVertices , filledVertexSet ) ; } } } } else { if ( ! currentComp . contains ( vertex ) ) { Set < Object > matchComp = null ; for ( Set < Object > comp : hierarchyVertices ) { if ( comp . contains ( vertex ) ) { currentComp . addAll ( comp ) ; matchComp = comp ; break ; } } if ( matchComp != null ) { hierarchyVertices . remove ( matchComp ) ; } } } } }
Traverses the (directed) graph invoking the given function for each
 visited vertex and edge.
Traverses the ( directed ) graph invoking the given function for each visited vertex and edge .
// Has this vertex been seen before in any traversal // And if the filled vertex set is populated, only  // process vertices in that it contains // We've seen this vertex before, but not in the current component // This component and the one it's in need to be merged