Package com.mxgraph.analysis
Class mxGraphStructure
- java.lang.Object
-
- com.mxgraph.analysis.mxGraphStructure
-
public class mxGraphStructure extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description mxGraphStructure()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
areConnected(mxAnalysisGraph aGraph, java.lang.Object sourceVertex, java.lang.Object targetVertex)
static void
complementaryGraph(mxAnalysisGraph aGraph)
Makes the complement of aGraphstatic java.lang.Object
getConnectingEdge(mxAnalysisGraph aGraph, java.lang.Object vertexOne, java.lang.Object vertexTwo)
static java.lang.Object[]
getCutEdges(mxAnalysisGraph aGraph)
static java.lang.Object[]
getCutVertices(mxAnalysisGraph aGraph)
static java.lang.Object
getDirectedLeaf(mxAnalysisGraph aGraph, java.lang.Object parent)
static java.lang.Object[][]
getGraphComponents(mxAnalysisGraph aGraph)
static java.lang.Object
getLowestDegreeVertex(mxAnalysisGraph aGraph, java.lang.Object[] omitVertex)
static java.lang.Object[]
getSinkVertices(mxAnalysisGraph aGraph)
static java.lang.Object[]
getSourceVertices(mxAnalysisGraph aGraph)
static java.lang.Object
getVertexWithValue(mxAnalysisGraph aGraph, int value)
static int
indegree(mxAnalysisGraph aGraph, java.lang.Object vertex)
static boolean
isBiconnected(mxAnalysisGraph aGraph)
static boolean
isConnected(mxAnalysisGraph aGraph)
static boolean
isCutEdge(mxAnalysisGraph aGraph, java.lang.Object edge)
static boolean
isCutVertex(mxAnalysisGraph aGraph, java.lang.Object vertex)
static boolean
isCyclicDirected(mxAnalysisGraph aGraph)
static boolean
isCyclicUndirected(mxAnalysisGraph aGraph)
static boolean
isSimple(mxAnalysisGraph aGraph)
static boolean
isTree(mxAnalysisGraph aGraph)
static void
makeConnected(mxAnalysisGraph aGraph)
Makes the graph connectedstatic void
makeSimple(mxAnalysisGraph aGraph)
static void
makeTreeDirected(mxAnalysisGraph aGraph, java.lang.Object startVertex)
Makes a tree graph directed from the source to the leavesstatic int
outdegree(mxAnalysisGraph aGraph, java.lang.Object vertex)
static int
regularity(mxAnalysisGraph aGraph)
static void
setDefaultGraphStyle(mxAnalysisGraph aGraph, boolean resetEdgeValues)
Sets the style of the graph to that as in GraphEditor
-
-
-
Method Detail
-
isConnected
public static boolean isConnected(mxAnalysisGraph aGraph)
- Parameters:
aGraph
-- Returns:
- true if the graph is connected
-
isCyclicUndirected
public static boolean isCyclicUndirected(mxAnalysisGraph aGraph)
- Parameters:
aGraph
-parent
-- Returns:
- true if the graph contains cycles regardless of edge direction
-
isSimple
public static boolean isSimple(mxAnalysisGraph aGraph)
- Parameters:
aGraph
-- Returns:
- true if the graph is simple (no self loops and no multiple edges)
-
isTree
public static boolean isTree(mxAnalysisGraph aGraph)
- Parameters:
aGraph
-- Returns:
- true if the graph has the structure of a tree, regardless of edge direction
-
getLowestDegreeVertex
public static java.lang.Object getLowestDegreeVertex(mxAnalysisGraph aGraph, java.lang.Object[] omitVertex)
- Parameters:
aGraph
-omitVertex
- vertices in this array will be omitted, set this parameter to null if you don't want this feature- Returns:
- a vertex that has lowest degree, or one of those in case if there are more
-
areConnected
public static boolean areConnected(mxAnalysisGraph aGraph, java.lang.Object sourceVertex, java.lang.Object targetVertex)
- Parameters:
graph
-sourceVertex
-targetVertex
-- Returns:
- Returns true if the two vertices are connected directly by an edge. If directed, the result is true if they are connected by an edge that points from source to target, if false direction isn't takein into account, just connectivity.
-
makeSimple
public static void makeSimple(mxAnalysisGraph aGraph)
- Parameters:
graph
- Make a graph simple (remove parallel edges and self loops)
-
makeConnected
public static void makeConnected(mxAnalysisGraph aGraph)
Makes the graph connected- Parameters:
aGraph
-
-
getGraphComponents
public static java.lang.Object[][] getGraphComponents(mxAnalysisGraph aGraph)
- Parameters:
aGraph
-- Returns:
- Object[components][vertices]
-
makeTreeDirected
public static void makeTreeDirected(mxAnalysisGraph aGraph, java.lang.Object startVertex) throws StructuralException
Makes a tree graph directed from the source to the leaves- Parameters:
aGraph
-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)
-
getConnectingEdge
public static java.lang.Object getConnectingEdge(mxAnalysisGraph aGraph, java.lang.Object vertexOne, java.lang.Object vertexTwo)
- Parameters:
aGraph
-vertexOne
-vertexTwo
-- Returns:
- an edge that directly connects vertexOne and vertexTwo regardless of direction, null if they are not connected directly
-
isCyclicDirected
public static boolean isCyclicDirected(mxAnalysisGraph aGraph)
- Parameters:
graph
-- Returns:
- Returns true if the graph has at least one cycle, taking edge direction into account
-
getDirectedLeaf
public static java.lang.Object getDirectedLeaf(mxAnalysisGraph aGraph, java.lang.Object parent)
- Parameters:
graph
-parent
-properties
-- Returns:
- A helper function for isDirectedCyclic and it isn't for general use. It returns a node that hasn't incoming or outgoing edges. It could be considered a "leaf" in a directed graph, but this definition isn't formal.
-
complementaryGraph
public static void complementaryGraph(mxAnalysisGraph aGraph)
Makes the complement of aGraph- Parameters:
aGraph
-
-
getVertexWithValue
public static java.lang.Object getVertexWithValue(mxAnalysisGraph aGraph, int value)
- Parameters:
aGraph
- - the graph to searchvalue
- - desired value- Returns:
- the first vertex with the wanted value. If none are found, null is returned
-
setDefaultGraphStyle
public static void setDefaultGraphStyle(mxAnalysisGraph aGraph, boolean resetEdgeValues)
Sets the style of the graph to that as in GraphEditor- Parameters:
aGraph
-resetEdgeValues
- - set to true if you want to re-generate edge weights
-
regularity
public static int regularity(mxAnalysisGraph aGraph) throws StructuralException
- Parameters:
aGraph
-- Returns:
- the regularity of the graph
- Throws:
StructuralException
- if the graph is irregular
-
indegree
public static int indegree(mxAnalysisGraph aGraph, java.lang.Object vertex)
- Parameters:
aGraph
-vertex
-- Returns:
- indegree of vertex
-
outdegree
public static int outdegree(mxAnalysisGraph aGraph, java.lang.Object vertex)
- Parameters:
aGraph
-vertex
-- Returns:
- outdegree of vertex
-
isCutVertex
public static boolean isCutVertex(mxAnalysisGraph aGraph, java.lang.Object vertex)
- Parameters:
aGraph
-vertex
-- Returns:
- true if vertex is a cut vertex
-
getCutVertices
public static java.lang.Object[] getCutVertices(mxAnalysisGraph aGraph)
- Parameters:
aGraph
-- Returns:
- all cut vertices of aGraph
-
isCutEdge
public static boolean isCutEdge(mxAnalysisGraph aGraph, java.lang.Object edge)
- Parameters:
aGraph
-edge
-- Returns:
- true if edge is a cut edge of aGraph
-
getCutEdges
public static java.lang.Object[] getCutEdges(mxAnalysisGraph aGraph)
- Parameters:
aGraph
-- Returns:
- all cut edges of aGraph
-
getSourceVertices
public static java.lang.Object[] getSourceVertices(mxAnalysisGraph aGraph) throws StructuralException
- Parameters:
aGraph
-- Returns:
- all source vertices of aGraph
- Throws:
StructuralException
- the graph must be directed
-
getSinkVertices
public static java.lang.Object[] getSinkVertices(mxAnalysisGraph aGraph) throws StructuralException
- Parameters:
aGraph
-- Returns:
- all sink vertices of aGraph
- Throws:
StructuralException
- the graph must be directed
-
isBiconnected
public static boolean isBiconnected(mxAnalysisGraph aGraph)
- Parameters:
aGraph
-- Returns:
- true if aGraph is biconnected
-
-