<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">java.lang.Object</A>
<IMGSRC="../../../resources/inherit.gif"ALT="extended by "><B>com.mxgraph.analysis.mxGraphAnalysis</B>
</PRE>
<HR>
<DL>
<DT><PRE>public class <B>mxGraphAnalysis</B><DT>extends <AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A></DL>
</PRE>
<P>
A singleton class that provides algorithms for graphs. Assume these
variables for the following examples:<br>
<code>
mxICostFunction cf = mxDistanceCostFunction();
Object[] v = graph.getChildVertices(graph.getDefaultParent());
Object[] e = graph.getChildEdges(graph.getDefaultParent());
mxGraphAnalysis mga = mxGraphAnalysis.getInstance();
</code>
<h3>Shortest Path (Dijkstra)</h3>
For example, to find the shortest path between the first and the second
selected cell in a graph use the following code: <br>
<br>
<code>Object[] path = mga.getShortestPath(graph, from, to, cf, v.length, true);</code>
<h3>Minimum Spanning Tree</h3>
This algorithm finds the set of edges with the minimal length that connect
all vertices. This algorithm can be used as follows:
<DT><B>See Also:</B><DD><AHREF="../../../com/mxgraph/analysis/mxICostFunction.html"title="interface in com.mxgraph.analysis"><CODE>mxICostFunction</CODE></A></DL>
<CODE>protected static <AHREF="../../../com/mxgraph/analysis/mxGraphAnalysis.html"title="class in com.mxgraph.analysis">mxGraphAnalysis</A></CODE></FONT></TD>
<CODE>protected <AHREF="../../../com/mxgraph/analysis/mxFibonacciHeap.html"title="class in com.mxgraph.analysis">mxFibonacciHeap</A></CODE></FONT></TD>
<CODE>protected <AHREF="../../../com/mxgraph/analysis/mxUnionFind.html"title="class in com.mxgraph.analysis">mxUnionFind</A></CODE></FONT></TD>
<TD><CODE><B><AHREF="../../../com/mxgraph/analysis/mxGraphAnalysis.html#createUnionFind(java.lang.Object[])">createUnionFind</A></B>(<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[] v)</CODE>
<BR>
Hook for subclassers to provide a custom union find structure.</TD>
<CODE> <AHREF="../../../com/mxgraph/analysis/mxUnionFind.html"title="class in com.mxgraph.analysis">mxUnionFind</A></CODE></FONT></TD>
<TD><CODE><B><AHREF="../../../com/mxgraph/analysis/mxGraphAnalysis.html#getConnectionComponents(com.mxgraph.view.mxGraph, java.lang.Object[], java.lang.Object[])">getConnectionComponents</A></B>(<AHREF="../../../com/mxgraph/view/mxGraph.html"title="class in com.mxgraph.view">mxGraph</A> graph,
<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[] v,
<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[] e)</CODE>
<BR>
Returns a union find structure representing the connection components of
<CODE>static <AHREF="../../../com/mxgraph/analysis/mxGraphAnalysis.html"title="class in com.mxgraph.analysis">mxGraphAnalysis</A></CODE></FONT></TD>
<CODE> <AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[]</CODE></FONT></TD>
<TD><CODE><B><AHREF="../../../com/mxgraph/analysis/mxGraphAnalysis.html#getMinimumSpanningTree(com.mxgraph.view.mxGraph, java.lang.Object[], com.mxgraph.analysis.mxICostFunction, boolean)">getMinimumSpanningTree</A></B>(<AHREF="../../../com/mxgraph/view/mxGraph.html"title="class in com.mxgraph.view">mxGraph</A> graph,
<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[] v,
<AHREF="../../../com/mxgraph/analysis/mxICostFunction.html"title="interface in com.mxgraph.analysis">mxICostFunction</A> cf,
boolean directed)</CODE>
<BR>
Returns the minimum spanning tree (MST) for the graph defined by G=(E,V).</TD>
<CODE> <AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[]</CODE></FONT></TD>
<TD><CODE><B><AHREF="../../../com/mxgraph/analysis/mxGraphAnalysis.html#getMinimumSpanningTree(com.mxgraph.view.mxGraph, java.lang.Object[], java.lang.Object[], com.mxgraph.analysis.mxICostFunction)">getMinimumSpanningTree</A></B>(<AHREF="../../../com/mxgraph/view/mxGraph.html"title="class in com.mxgraph.view">mxGraph</A> graph,
<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[] v,
<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[] e,
<AHREF="../../../com/mxgraph/analysis/mxICostFunction.html"title="interface in com.mxgraph.analysis">mxICostFunction</A> cf)</CODE>
<BR>
Returns the minimum spanning tree (MST) for the graph defined by G=(E,V).</TD>
<CODE> <AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[]</CODE></FONT></TD>
<TD><CODE><B><AHREF="../../../com/mxgraph/analysis/mxGraphAnalysis.html#getShortestPath(com.mxgraph.view.mxGraph, java.lang.Object, java.lang.Object, com.mxgraph.analysis.mxICostFunction, int, boolean)">getShortestPath</A></B>(<AHREF="../../../com/mxgraph/view/mxGraph.html"title="class in com.mxgraph.view">mxGraph</A> graph,
<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A> from,
<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A> to,
<AHREF="../../../com/mxgraph/analysis/mxICostFunction.html"title="interface in com.mxgraph.analysis">mxICostFunction</A> cf,
int steps,
boolean directed)</CODE>
<BR>
Returns the shortest path between two cells or their descendants
represented as an array of edges in order of traversal.</TD>
<TD><CODE><B><AHREF="../../../com/mxgraph/analysis/mxGraphAnalysis.html#setInstance(com.mxgraph.analysis.mxGraphAnalysis)">setInstance</A></B>(<AHREF="../../../com/mxgraph/analysis/mxGraphAnalysis.html"title="class in com.mxgraph.analysis">mxGraphAnalysis</A> instance)</CODE>
<BR>
Sets the shared instance of this class.</TD>
<CODE> <AHREF="../../../com/mxgraph/view/mxCellState.html"title="class in com.mxgraph.view">mxCellState</A>[]</CODE></FONT></TD>
<TD><CODE><B><AHREF="../../../com/mxgraph/analysis/mxGraphAnalysis.html#sort(com.mxgraph.view.mxCellState[], com.mxgraph.analysis.mxICostFunction)">sort</A></B>(<AHREF="../../../com/mxgraph/view/mxCellState.html"title="class in com.mxgraph.view">mxCellState</A>[] states,
<AHREF="../../../com/mxgraph/analysis/mxICostFunction.html"title="interface in com.mxgraph.analysis">mxICostFunction</A> cf)</CODE>
<BR>
Returns a sorted set for <code>cells</code> with respect to
<TD><CODE><B><AHREF="../../../com/mxgraph/analysis/mxGraphAnalysis.html#sum(com.mxgraph.view.mxCellState[], com.mxgraph.analysis.mxICostFunction)">sum</A></B>(<AHREF="../../../com/mxgraph/view/mxCellState.html"title="class in com.mxgraph.view">mxCellState</A>[] states,
<AHREF="../../../com/mxgraph/analysis/mxICostFunction.html"title="interface in com.mxgraph.analysis">mxICostFunction</A> cf)</CODE>
<BR>
Returns the sum of all cost for <code>cells</code> with respect to
<THALIGN="left"><B>Methods inherited from class java.lang.<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A></B></TH>
</TR>
<TRBGCOLOR="white"CLASS="TableRowColor">
<TD><CODE><AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#clone()"title="class or interface in java.lang">clone</A>, <AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)"title="class or interface in java.lang">equals</A>, <AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#finalize()"title="class or interface in java.lang">finalize</A>, <AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#getClass()"title="class or interface in java.lang">getClass</A>, <AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#hashCode()"title="class or interface in java.lang">hashCode</A>, <AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#notify()"title="class or interface in java.lang">notify</A>, <AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#notifyAll()"title="class or interface in java.lang">notifyAll</A>, <AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#toString()"title="class or interface in java.lang">toString</A>, <AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait()"title="class or interface in java.lang">wait</A>, <AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait(long)"title="class or interface in java.lang">wait</A>, <AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true#wait(long, int)"title="class or interface in java.lang">wait</A></CODE></TD>
protected static <AHREF="../../../com/mxgraph/analysis/mxGraphAnalysis.html"title="class in com.mxgraph.analysis">mxGraphAnalysis</A><B>instance</B></PRE>
public static <AHREF="../../../com/mxgraph/analysis/mxGraphAnalysis.html"title="class in com.mxgraph.analysis">mxGraphAnalysis</A><B>getInstance</B>()</PRE>
<DL>
<DD><DL>
<DT><B>Returns:</B><DD>Returns the sharedInstance.</DL>
public static void <B>setInstance</B>(<AHREF="../../../com/mxgraph/analysis/mxGraphAnalysis.html"title="class in com.mxgraph.analysis">mxGraphAnalysis</A> instance)</PRE>
<DL>
<DD>Sets the shared instance of this class.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>instance</CODE> - The instance to set.</DL>
public <AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[] <B>getShortestPath</B>(<AHREF="../../../com/mxgraph/view/mxGraph.html"title="class in com.mxgraph.view">mxGraph</A> graph,
<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A> from,
<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A> to,
<AHREF="../../../com/mxgraph/analysis/mxICostFunction.html"title="interface in com.mxgraph.analysis">mxICostFunction</A> cf,
int steps,
boolean directed)</PRE>
<DL>
<DD>Returns the shortest path between two cells or their descendants
represented as an array of edges in order of traversal. <br>
This implementation is based on the Dijkstra algorithm.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>graph</CODE> - The object that defines the graph structure<DD><CODE>from</CODE> - The source cell.<DD><CODE>to</CODE> - The target cell (aka sink).<DD><CODE>cf</CODE> - The cost function that defines the edge length.<DD><CODE>steps</CODE> - The maximum number of edges to traverse.<DD><CODE>directed</CODE> - If edge directions should be taken into account.
<DT><B>Returns:</B><DD>Returns the shortest path as an alternating array of vertices
and edges, starting with <code>from</code> and ending with
public <AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[] <B>getMinimumSpanningTree</B>(<AHREF="../../../com/mxgraph/view/mxGraph.html"title="class in com.mxgraph.view">mxGraph</A> graph,
<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[] v,
<AHREF="../../../com/mxgraph/analysis/mxICostFunction.html"title="interface in com.mxgraph.analysis">mxICostFunction</A> cf,
boolean directed)</PRE>
<DL>
<DD>Returns the minimum spanning tree (MST) for the graph defined by G=(E,V).
The MST is defined as the set of all vertices with minimal lengths that
forms no cycles in G.<br>
This implementation is based on the algorihm by Prim-Jarnik. It uses
O(|E|+|V|log|V|) time when used with a Fibonacci heap and a graph whith a
double linked-list datastructure, as is the case with the default
implementation.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>graph</CODE> - the object that describes the graph<DD><CODE>v</CODE> - the vertices of the graph<DD><CODE>cf</CODE> - the cost function that defines the edge length
<DT><B>Returns:</B><DD>Returns the MST as an array of edges<DT><B>See Also:</B><DD><AHREF="../../../com/mxgraph/analysis/mxGraphAnalysis.html#createPriorityQueue()"><CODE>createPriorityQueue()</CODE></A></DL>
public <AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[] <B>getMinimumSpanningTree</B>(<AHREF="../../../com/mxgraph/view/mxGraph.html"title="class in com.mxgraph.view">mxGraph</A> graph,
<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[] v,
<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[] e,
<AHREF="../../../com/mxgraph/analysis/mxICostFunction.html"title="interface in com.mxgraph.analysis">mxICostFunction</A> cf)</PRE>
<DL>
<DD>Returns the minimum spanning tree (MST) for the graph defined by G=(E,V).
The MST is defined as the set of all vertices with minimal lenths that
forms no cycles in G.<br>
This implementation is based on the algorihm by Kruskal. It uses
O(|E|log|E|)=O(|E|log|V|) time for sorting the edges, O(|V|) create sets,
O(|E|) find and O(|V|) union calls on the union find structure, thus
yielding no more than O(|E|log|V|) steps. For a faster implementatin
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>graph</CODE> - The object that contains the graph.<DD><CODE>v</CODE> - The vertices of the graph.<DD><CODE>e</CODE> - The edges of the graph.<DD><CODE>cf</CODE> - The cost function that defines the edge length.
<DT><B>Returns:</B><DD>Returns the MST as an array of edges.<DT><B>See Also:</B><DD><AHREF="../../../com/mxgraph/analysis/mxGraphAnalysis.html#getMinimumSpanningTree(com.mxgraph.view.mxGraph, java.lang.Object[], com.mxgraph.analysis.mxICostFunction, boolean)"><CODE>getMinimumSpanningTree(mxGraph, Object[], mxICostFunction,
public <AHREF="../../../com/mxgraph/analysis/mxUnionFind.html"title="class in com.mxgraph.analysis">mxUnionFind</A><B>getConnectionComponents</B>(<AHREF="../../../com/mxgraph/view/mxGraph.html"title="class in com.mxgraph.view">mxGraph</A> graph,
<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[] v,
<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[] e)</PRE>
<DL>
<DD>Returns a union find structure representing the connection components of
G=(E,V).
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>graph</CODE> - The object that contains the graph.<DD><CODE>v</CODE> - The vertices of the graph.<DD><CODE>e</CODE> - The edges of the graph.
<DT><B>Returns:</B><DD>Returns the connection components in G=(E,V)<DT><B>See Also:</B><DD><AHREF="../../../com/mxgraph/analysis/mxGraphAnalysis.html#createUnionFind(java.lang.Object[])"><CODE>createUnionFind(Object[])</CODE></A></DL>
public <AHREF="../../../com/mxgraph/view/mxCellState.html"title="class in com.mxgraph.view">mxCellState</A>[] <B>sort</B>(<AHREF="../../../com/mxgraph/view/mxCellState.html"title="class in com.mxgraph.view">mxCellState</A>[] states,
<AHREF="../../../com/mxgraph/analysis/mxICostFunction.html"title="interface in com.mxgraph.analysis">mxICostFunction</A> cf)</PRE>
<DL>
<DD>Returns a sorted set for <code>cells</code> with respect to
<code>cf</code>.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>states</CODE> - the cell states to sort<DD><CODE>cf</CODE> - the cost function that defines the order
<DT><B>Returns:</B><DD>Returns an ordered set of <code>cells</code> wrt.
protected <AHREF="../../../com/mxgraph/analysis/mxUnionFind.html"title="class in com.mxgraph.analysis">mxUnionFind</A><B>createUnionFind</B>(<AHREF="http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Object.html?is-external=true"title="class or interface in java.lang">Object</A>[] v)</PRE>
<DL>
<DD>Hook for subclassers to provide a custom union find structure.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>v</CODE> - the array of all elements
<DT><B>Returns:</B><DD>Returns a union find structure for <code>v</code></DL>
</DD>
</DL>
<HR>
<ANAME="createPriorityQueue()"><!----></A><H3>
createPriorityQueue</H3>
<PRE>
protected <AHREF="../../../com/mxgraph/analysis/mxFibonacciHeap.html"title="class in com.mxgraph.analysis">mxFibonacciHeap</A><B>createPriorityQueue</B>()</PRE>
<DL>
<DD>Hook for subclassers to provide a custom fibonacci heap.