src/main/java/com/mxgraph/analysis/mxGraphStructure.java
public static boolean isCyclicDirected(mxAnalysisGraph aGraph)
	{
		mxGraph graph = aGraph.getGraph();
		mxIGraphModel model = graph.getModel();
		Object[] cells = model.cloneCells(aGraph.getChildCells(graph.getDefaultParent(), true, true), true);
		mxGraphModel modelCopy = new mxGraphModel();
		mxGraph graphCopy = new mxGraph(modelCopy);
		Object parentCopy = graphCopy.getDefaultParent();
		graphCopy.addCells(cells);
		mxAnalysisGraph aGraphCopy = new mxAnalysisGraph();
		aGraphCopy.setGraph(graphCopy);
		aGraphCopy.setGenerator(aGraph.getGenerator());
		aGraphCopy.setProperties(aGraph.getProperties());

		Object[] leaf = new Object[1];

		do
		{
			leaf[0] = getDirectedLeaf(aGraphCopy, parentCopy);

			if (leaf[0] != null)
			{
				graphCopy.removeCells(leaf);
			}
		}
		while (leaf[0] != null);

		int vertexNum = aGraphCopy.getChildVertices(parentCopy).length;

		if (vertexNum > 0)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
/**
	 * @param graph
	 * @return Returns true if the graph has at least one cycle, taking edge direction into account
	 */
@param graph
@return Returns true if the graph has at least one cycle, taking edge direction into account
@param graph @return Returns true if the graph has at least one cycle taking edge direction into account
public static boolean isCyclicDirected(mxAnalysisGraph aGraph)
	{
		mxGraph graph = aGraph.getGraph();
		mxIGraphModel model = graph.getModel();
		Object[] cells = model.cloneCells(aGraph.getChildCells(graph.getDefaultParent(), true, true), true);
		mxGraphModel modelCopy = new mxGraphModel();
		mxGraph graphCopy = new mxGraph(modelCopy);
		Object parentCopy = graphCopy.getDefaultParent();
		graphCopy.addCells(cells);
		mxAnalysisGraph aGraphCopy = new mxAnalysisGraph();
		aGraphCopy.setGraph(graphCopy);
		aGraphCopy.setGenerator(aGraph.getGenerator());
		aGraphCopy.setProperties(aGraph.getProperties());
		Object[] leaf = new Object[1];
		do
		{
			leaf[0] = getDirectedLeaf(aGraphCopy, parentCopy);
			if (leaf[0] != null)
			{
				graphCopy.removeCells(leaf);
			}
		}
		while (leaf[0] != null);
		int vertexNum = aGraphCopy.getChildVertices(parentCopy).length;
		if (vertexNum > 0)
		{
			return true;
		}
		else
		{
			return false;
		}
	}
public static boolean isCyclicDirected ( mxAnalysisGraph aGraph ) { mxGraph graph = aGraph . getGraph ( ) ; mxIGraphModel model = graph . getModel ( ) ; Object [ ] cells = model . cloneCells ( aGraph . getChildCells ( graph . getDefaultParent ( ) , true , true ) , true ) ; mxGraphModel modelCopy = new mxGraphModel ( ) ; mxGraph graphCopy = new mxGraph ( modelCopy ) ; Object parentCopy = graphCopy . getDefaultParent ( ) ; graphCopy . addCells ( cells ) ; mxAnalysisGraph aGraphCopy = new mxAnalysisGraph ( ) ; aGraphCopy . setGraph ( graphCopy ) ; aGraphCopy . setGenerator ( aGraph . getGenerator ( ) ) ; aGraphCopy . setProperties ( aGraph . getProperties ( ) ) ; Object [ ] leaf = new Object [ 1 ] ; do { leaf [ 0 ] = getDirectedLeaf ( aGraphCopy , parentCopy ) ; if ( leaf [ 0 ] != null ) { graphCopy . removeCells ( leaf ) ; } } while ( leaf [ 0 ] != null ) ; int vertexNum = aGraphCopy . getChildVertices ( parentCopy ) . length ; if ( vertexNum > 0 ) { return true ; } else { return false ; } }
@param graph
 @return Returns true if the graph has at least one cycle, taking edge direction into account
@param graph @return Returns true if the graph has at least one cycle taking edge direction into account