|
JGraph |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jgraph.algebra.JGraphAlgebra
public class JGraphAlgebra
A singleton class that provides algorithms for graphs. Assume the following
variable for the following examples:
JGraphDistanceCostFunction(graph.getGraphLayoutCache());
JGraphFacade facade = new JGraphFacade(graph);
Object[] v = facade.getVertices().toArray();
Object[] e = facade.getEdges().toArray();
JGraphAlgebra alg = JGraphAlgebra.getSharedInstance();
Object[] path = alg.getShortestPath(graph.getModel(), sourceVertex,
targetVertex, cf, v.length, true)
alg.getMinimumSpanningTree(graph.getModel(), v, cf, true))
alg.getMinimumSpanningTree(graph.getModel(), v, e, cf))
boolean connected = uf.differ(vertex1, vertex2)
.
JGraphCostFunction
Field Summary | |
---|---|
protected static JGraphAlgebra |
sharedInstance
Holds the shared instance of this class. |
Constructor Summary | |
---|---|
protected |
JGraphAlgebra()
Subclassers may override to provide special union find and priority queue datastructures. |
Method Summary | |
---|---|
protected JGraphFibonacciHeap |
createPriorityQueue()
Hook for subclassers to provide a custom fibonacci heap. |
protected JGraphUnionFind |
createUnionFind(Object[] v)
Hook for subclassers to provide a custom union find structure. |
JGraphUnionFind |
getConnectionComponents(GraphModel model,
Object[] v,
Object[] e)
Returns a union find structure representing the connection components of G=(E,V). |
Object[] |
getMinimumSpanningTree(GraphModel model,
Object[] v,
JGraphCostFunction cf,
boolean directed)
Returns the minimum spanning tree (MST) for the graph defined by G=(E,V). |
Object[] |
getMinimumSpanningTree(GraphModel model,
Object[] v,
Object[] e,
JGraphCostFunction cf)
Returns the minimum spanning tree (MST) for the graph defined by G=(E,V). |
static JGraphAlgebra |
getSharedInstance()
|
Object[] |
getShortestPath(GraphModel model,
Object from,
Object to,
JGraphCostFunction cf,
int steps,
boolean directed)
Returns the shortest path between two cells or their descendants represented as an array of edges in order of traversal. |
static void |
setSharedInstance(JGraphAlgebra sharedInstance)
Sets the shared instance of this class. |
List |
sort(Object[] cells,
JGraphCostFunction cf)
Returns a sorted set for cells with respect to
cf . |
double |
sum(Object[] cells,
JGraphCostFunction cf)
Returns the sum of all cost for cells with respect to
cf . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static JGraphAlgebra sharedInstance
Constructor Detail |
---|
protected JGraphAlgebra()
Method Detail |
---|
public static JGraphAlgebra getSharedInstance()
public static void setSharedInstance(JGraphAlgebra sharedInstance)
sharedInstance
- The sharedInstance to set.public Object[] getShortestPath(GraphModel model, Object from, Object to, JGraphCostFunction cf, int steps, boolean directed)
model
- the model that defines the graph structurefrom
- the source port or vertexto
- the target port or vertex (aka. sink)cf
- the cost function that defines the edge lengthsteps
- the maximum number of edges to traversedirected
- if edge directions should be taken into account
createPriorityQueue()
public Object[] getMinimumSpanningTree(GraphModel model, Object[] v, JGraphCostFunction cf, boolean directed)
model
- the model that describes the graphv
- the vertices of the graphcf
- the cost function that defines the edge length
createPriorityQueue()
public Object[] getMinimumSpanningTree(GraphModel model, Object[] v, Object[] e, JGraphCostFunction cf)
model
- the model that describes the graphv
- the vertices of the graphe
- the edges of the graphcf
- the cost function that defines the edge length
getMinimumSpanningTree(GraphModel, Object[], JGraphCostFunction,
boolean)
,
createUnionFind(Object[])
public JGraphUnionFind getConnectionComponents(GraphModel model, Object[] v, Object[] e)
model
- the model that describes the graphv
- the vertices of the graphe
- the edges of the graph
createUnionFind(Object[])
public List sort(Object[] cells, JGraphCostFunction cf)
cells
with respect to
cf
.
cells
- the cells to sortcf
- the cost function that defines the order
cells
wrt.
cf
public double sum(Object[] cells, JGraphCostFunction cf)
cells
with respect to
cf
.
cells
- the cells to use for the sumcf
- the cost function that defines the costs
protected JGraphUnionFind createUnionFind(Object[] v)
v
- the array of all elements
v
protected JGraphFibonacciHeap createPriorityQueue()
|
JGraph |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |