Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
JGraphX Swing Component - Java Graph Visualization Library
This is a binary & source redistribution of the original, unmodified JGraphX library originating from:
"https://github.com/jgraph/jgraphx/archive/v3.4.1.3.zip".
The purpose of this redistribution is to make the library available to other Maven projects.
/*
* $Id: mxGraphAnalysis.java,v 1.4 2012/03/09 07:42:54 gaudenz Exp $
* Copyright (c) 2001-2005, Gaudenz Alder
*
* All rights reserved.
*
* This file is licensed under the JGraph software license, a copy of which
* will have been provided to you in the file LICENSE at the root of your
* installation directory. If you are unable to locate this file please
* contact JGraph sales for another copy.
*/
package com.mxgraph.analysis;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Hashtable;
import java.util.List;
import com.mxgraph.view.mxCellState;
import com.mxgraph.view.mxGraph;
import com.mxgraph.view.mxGraphView;
/**
* A singleton class that provides algorithms for graphs. Assume these
* variables for the following examples:
*
* mxICostFunction cf = mxDistanceCostFunction();
* Object[] v = graph.getChildVertices(graph.getDefaultParent());
* Object[] e = graph.getChildEdges(graph.getDefaultParent());
* mxGraphAnalysis mga = mxGraphAnalysis.getInstance();
*
*
*
Shortest Path (Dijkstra)
*
* For example, to find the shortest path between the first and the second
* selected cell in a graph use the following code:
*
* Object[] path = mga.getShortestPath(graph, from, to, cf, v.length, true);
*
*
Minimum Spanning Tree
*
* This algorithm finds the set of edges with the minimal length that connect
* all vertices. This algorithm can be used as follows:
*
* mga.getMinimumSpanningTree(graph, v, e, cf))
*
*
Connection Components
*
* The union find may be used as follows to determine whether two cells are
* connected: boolean connected = uf.differ(vertex1, vertex2).
*
* @see mxICostFunction
*/
public class mxGraphAnalysis
{
/**
* Holds the shared instance of this class.
*/
protected static mxGraphAnalysis instance = new mxGraphAnalysis();
/**
*
*/
protected mxGraphAnalysis()
{
// empty
}
/**
* @return Returns the sharedInstance.
*/
public static mxGraphAnalysis getInstance()
{
return instance;
}
/**
* Sets the shared instance of this class.
*
* @param instance The instance to set.
*/
public static void setInstance(mxGraphAnalysis instance)
{
mxGraphAnalysis.instance = instance;
}
/**
* Returns the shortest path between two cells or their descendants
* represented as an array of edges in order of traversal.
* This implementation is based on the Dijkstra algorithm.
*
* @param graph The object that defines the graph structure
* @param from The source cell.
* @param to The target cell (aka sink).
* @param cf The cost function that defines the edge length.
* @param steps The maximum number of edges to traverse.
* @param directed If edge directions should be taken into account.
* @return Returns the shortest path as an alternating array of vertices
* and edges, starting with from and ending with
* to.
*
* @see #createPriorityQueue()
*/
public Object[] getShortestPath(mxGraph graph, Object from, Object to,
mxICostFunction cf, int steps, boolean directed)
{
// Sets up a pqueue and a hashtable to store the predecessor for each
// cell in tha graph traversal. The pqueue is initialized
// with the from element at prio 0.
mxGraphView view = graph.getView();
mxFibonacciHeap q = createPriorityQueue();
Hashtable