src/main/java/com/mxgraph/analysis/mxGraphStructure.java
public static void makeTreeDirected(mxAnalysisGraph aGraph, Object startVertex) throws StructuralException
	{
		if (isTree(aGraph))
		{
			mxGraphProperties.setDirected(aGraph.getProperties(), false);
			final ArrayList<Object> bFSList = new ArrayList<Object>();
			mxGraph graph = aGraph.getGraph();
			final mxIGraphModel model = graph.getModel();
			Object parent = graph.getDefaultParent();

			mxTraversal.bfs(aGraph, startVertex, new mxICellVisitor()
			{
				public boolean visit(Object vertex, Object edge)
				{
					bFSList.add(vertex);
					return false;
				}
			});

			for (int i = 0; i < bFSList.size(); i++)
			{
				Object parentVertex = bFSList.get(i);
				Object currEdges[] = aGraph.getEdges(parentVertex, parent, true, true, false, true);
				Object[] neighbors = aGraph.getOpposites(currEdges, parentVertex, true, true);

				for (int j = 0; j < neighbors.length; j++)
				{
					Object currVertex = neighbors[j];
					int childIndex = bFSList.indexOf(currVertex);

					if (childIndex > i)
					{
						//parentVertex is parent of currVertex, so the edge must be directed from parentVertex to currVertex
						// but we need to find the connecting edge first
						Object currEdge = getConnectingEdge(aGraph, parentVertex, currVertex);
						model.setTerminal(currEdge, parentVertex, true);
						model.setTerminal(currEdge, currVertex, false);
					}
				}
			}

			mxGraphProperties.setDirected(aGraph.getProperties(), true);
			mxGraphStructure.setDefaultGraphStyle(aGraph, false);
		}
		else
		{
			throw new StructuralException("The graph is not a tree");
		}
	}
/**
	 * Makes a tree graph directed from the source to the leaves
	 * @param aGraph
	 * @param startVertex - this vertex will be root of the tree (the only source node)
	 * @throws StructuralException - the graph must be a tree (edge direction doesn't matter)
	 */
Makes a tree graph directed from the source to the leaves
@param aGraph
@param startVertex - this vertex will be root of the tree (the only source node)
@throws StructuralException - the graph must be a tree (edge direction doesn't matter)
Makes a tree graph directed from the source to the leaves @param aGraph @param startVertex - this vertex will be root of the tree ( the only source node ) @throws StructuralException - the graph must be a tree ( edge direction doesn ' t matter )
public static void makeTreeDirected(mxAnalysisGraph aGraph, Object startVertex) throws StructuralException
	{
		if (isTree(aGraph))
		{
			mxGraphProperties.setDirected(aGraph.getProperties(), false);
			final ArrayList<Object> bFSList = new ArrayList<Object>();
			mxGraph graph = aGraph.getGraph();
			final mxIGraphModel model = graph.getModel();
			Object parent = graph.getDefaultParent();
			mxTraversal.bfs(aGraph, startVertex, new mxICellVisitor()
			{
				public boolean visit(Object vertex, Object edge)
				{
					bFSList.add(vertex);
					return false;
				}
			});
			for (int i = 0; i < bFSList.size(); i++)
			{
				Object parentVertex = bFSList.get(i);
				Object currEdges[] = aGraph.getEdges(parentVertex, parent, true, true, false, true);
				Object[] neighbors = aGraph.getOpposites(currEdges, parentVertex, true, true);
				for (int j = 0; j < neighbors.length; j++)
				{
					Object currVertex = neighbors[j];
					int childIndex = bFSList.indexOf(currVertex);
					if (childIndex > i)
					{
						Object currEdge = getConnectingEdge(aGraph, parentVertex, currVertex);
						model.setTerminal(currEdge, parentVertex, true);
						model.setTerminal(currEdge, currVertex, false);
					}
				}
			}
			mxGraphProperties.setDirected(aGraph.getProperties(), true);
			mxGraphStructure.setDefaultGraphStyle(aGraph, false);
		}
		else
		{
			throw new StructuralException("The graph is not a tree");
		}
	}
public static void makeTreeDirected ( mxAnalysisGraph aGraph , Object startVertex ) throws StructuralException { if ( isTree ( aGraph ) ) { mxGraphProperties . setDirected ( aGraph . getProperties ( ) , false ) ; final ArrayList < Object > bFSList = new ArrayList < Object > ( ) ; mxGraph graph = aGraph . getGraph ( ) ; final mxIGraphModel model = graph . getModel ( ) ; Object parent = graph . getDefaultParent ( ) ; mxTraversal . bfs ( aGraph , startVertex , new mxICellVisitor ( ) { public boolean visit ( Object vertex , Object edge ) { bFSList . add ( vertex ) ; return false ; } } ) ; for ( int i = 0 ; i < bFSList . size ( ) ; i ++ ) { Object parentVertex = bFSList . get ( i ) ; Object currEdges [ ] = aGraph . getEdges ( parentVertex , parent , true , true , false , true ) ; Object [ ] neighbors = aGraph . getOpposites ( currEdges , parentVertex , true , true ) ; for ( int j = 0 ; j < neighbors . length ; j ++ ) { Object currVertex = neighbors [ j ] ; int childIndex = bFSList . indexOf ( currVertex ) ; if ( childIndex > i ) { Object currEdge = getConnectingEdge ( aGraph , parentVertex , currVertex ) ; model . setTerminal ( currEdge , parentVertex , true ) ; model . setTerminal ( currEdge , currVertex , false ) ; } } } mxGraphProperties . setDirected ( aGraph . getProperties ( ) , true ) ; mxGraphStructure . setDefaultGraphStyle ( aGraph , false ) ; } else { throw new StructuralException ( "The graph is not a tree" ) ; } }
Makes a tree graph directed from the source to the leaves
 @param aGraph
 @param startVertex - this vertex will be root of the tree (the only source node)
 @throws StructuralException - the graph must be a tree (edge direction doesn't matter)
Makes a tree graph directed from the source to the leaves @param aGraph @param startVertex - this vertex will be root of the tree ( the only source node ) @throws StructuralException - the graph must be a tree ( edge direction doesn ' t matter )
//parentVertex is parent of currVertex, so the edge must be directed from parentVertex to currVertex // but we need to find the connecting edge first