Package org.graph4j
Class GraphTests
java.lang.Object
org.graph4j.GraphTests
- Author:
- Cristian Frăsinaru
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanhasOreProperty(Graph graph) Checks if an undirected graph has Ore's property:deg(v) + deg(u) >= |V|, for every pair of distinct non-adjacent vertices v and u.static booleanDetermines if the graph is acyclic, meaning it does not contain any cycle.static booleanisArborescence(Digraph digraph) Determines if a directed graph is an arborescence (also called poly-tree), that is a directed rooted tree in which all edges point away from the root.static booleanisBiconnected(Graph graph) Determines if the graph is biconnected (2-connected). that is it does not contain a cut-vertex.static booleanisBipartite(Graph graph) Determines if a graph is bipartite, meaning that its vertices can be partitioned in two disjoint stable sets.static booleanisBranching(Digraph digraph) Determines if a directed graph is a branching (also called poly-forest), that is a collection of disjoint arborescences.static booleanisBridgeless(Graph graph) Determines if the graph is bridgeless, that is it does not contain any bridge.static booleanDetermines if a graph is chordal, meaning it does not contain an induced cycle of four or more vertices.static booleanChecks if the specified vertices represent a clique, meaning that the subgraph induced by them is complete.static booleanisConnected(Graph graph) Determines if a graph is connected, meaning that there exists a path between every pair of vertices.static booleanDetermines if a graph is cubic, meaning that all of its vertices have degree 3.static booleanisEulerian(Graph graph) Determines if a graph is Eulerian, that is it contains a circuit passing through all of its edges.static booleanDetermines if a graph is a forest, an undirected and acyclic graph.static booleanisOverfull(Graph graph) Checks if a graph is overfull, meaning its size is greater than the product of its maximum degree and half of its order floored:|E| > Δ(G) |V|/2, whereΔ(G)is the maximum degree of the graph.static booleanDetermines if the graph is regular, that is a graph where each vertex has the same number of neighbors (degree).static booleanDetermines if the graph is k-regular, that is a graph where each vertex has exactly k neighbors.static booleanisStableSet(Graph graph, int[] vertices) Checks if the specified vertices represent a stable set, meaning that the subgraph induced by them is edgeless.static booleanisStronglyConnected(Digraph digraph) Determines if a directed graph is strongly connected, that is for every pair of vertices u and v, there exists both directed paths from u to v and from v to u.static booleanDetermines if a graph is a tree, that is an undirected, connected and acyclic graph.static booleanisTriangleFree(Graph graph) Determines if a graph is triangle-free, that is no three distinct vertices form a triangle.static booleanisUnilateralConnected(Digraph digraph) Determines if a directed graph is unilateral connected, that is for every pair of vertices u and v, there exists either a directed path from u to v or one from v to u.static booleanisWeaklyConnected(Digraph digraph) Determines if a directed graph is weakly connected, that is its support graph is connected.
-
Constructor Details
-
GraphTests
public GraphTests()
-
-
Method Details
-
isBipartite
Determines if a graph is bipartite, meaning that its vertices can be partitioned in two disjoint stable sets.- Parameters:
graph- the input graph.- Returns:
trueif the graph is bipartite,falseotherwise.- See Also:
-
isConnected
Determines if a graph is connected, meaning that there exists a path between every pair of vertices. If the input graph is directed, the algorithm is performed on its support graph (it tests weak connectivity).- Parameters:
graph- the input graph.- Returns:
trueif the graph is connected,falseotherwise.- See Also:
-
isTree
Determines if a graph is a tree, that is an undirected, connected and acyclic graph. It uses the property that a tree hasn - 1edges, wherenis the number of vertices in the graph.- Parameters:
graph- the input graph.- Returns:
trueif the graph is a tree,falseotherwise.- Throws:
IllegalArgumentException- if the graph is directed.
-
isForest
Determines if a graph is a forest, an undirected and acyclic graph. A forest can also be defined as a disjoint reunion of trees.- Parameters:
graph- the input graph.- Returns:
trueif the graph is a forest,falseotherwise.- Throws:
IllegalArgumentException- if the graph is directed.
-
isArborescence
Determines if a directed graph is an arborescence (also called poly-tree), that is a directed rooted tree in which all edges point away from the root. Technically, an arborescence is a directed tree with maximum indegree equal to 1.- Parameters:
digraph- the input directed graph.- Returns:
trueif the digraph is an arborescence,falseotherwise.
-
isBranching
Determines if a directed graph is a branching (also called poly-forest), that is a collection of disjoint arborescences. Technically, a branching is a directed forest with maximum indegree equal to 1.- Parameters:
digraph- the input directed graph.- Returns:
trueif the digraph is a branching,falseotherwise.
-
isBiconnected
Determines if the graph is biconnected (2-connected). that is it does not contain a cut-vertex.- Parameters:
graph- the input graph- Returns:
trueif the graph is biconnected (2-connected),falseotherwise.- See Also:
-
isStronglyConnected
Determines if a directed graph is strongly connected, that is for every pair of vertices u and v, there exists both directed paths from u to v and from v to u.- Parameters:
digraph- the input directed graph.- Returns:
trueif the digraph is strongly connected,falseotherwise.- See Also:
-
isUnilateralConnected
Determines if a directed graph is unilateral connected, that is for every pair of vertices u and v, there exists either a directed path from u to v or one from v to u.- Parameters:
digraph- the input directed graph.- Returns:
trueif the digraph is unilateral connected,falseotherwise.- See Also:
-
isWeaklyConnected
Determines if a directed graph is weakly connected, that is its support graph is connected.- Parameters:
digraph- the input directed graph.- Returns:
trueif the digraph is weakly connected,falseotherwise.- See Also:
-
isBridgeless
Determines if the graph is bridgeless, that is it does not contain any bridge.- Parameters:
graph- the input graph- Returns:
trueif the graph does not contain any bridge.- See Also:
-
isAcyclic
Determines if the graph is acyclic, meaning it does not contain any cycle.- Parameters:
graph- the input graph.- Returns:
trueif the graph is acyclic,falseotherwise.- See Also:
-
isRegular
Determines if the graph is regular, that is a graph where each vertex has the same number of neighbors (degree). For a regular directed graph, the indegree and outdegree of each vertex must also be equal.- Parameters:
graph- an input graph.- Returns:
trueif all vertices have the same degree,falseotherwise.
-
isRegular
Determines if the graph is k-regular, that is a graph where each vertex has exactly k neighbors. For a k-regular directed graph, the indegree and outdegree of each vertex must both be equal to k.- Parameters:
graph- the input graph.k- a degree.- Returns:
trueif the graph is k-regular.
-
isCubic
Determines if a graph is cubic, meaning that all of its vertices have degree 3. In case of directed graphs, the indegree and outdegree of each vertex must both be equal to 3.- Parameters:
graph- the input graph.- Returns:
trueif the graph is cubic,falseotherwise.- See Also:
-
isEulerian
Determines if a graph is Eulerian, that is it contains a circuit passing through all of its edges.- Parameters:
graph- the input graph.- Returns:
trueif the graph is Eulerian.- See Also:
-
isTriangleFree
Determines if a graph is triangle-free, that is no three distinct vertices form a triangle.- Parameters:
graph- the input graph.- Returns:
trueif the graph is triangle-free.- See Also:
-
isChordal
Determines if a graph is chordal, meaning it does not contain an induced cycle of four or more vertices.- Parameters:
graph- the input graph.- Returns:
trueif the graph is chordal,falseotherwise.- See Also:
-
hasOreProperty
Checks if an undirected graph has Ore's property:deg(v) + deg(u) >= |V|, for every pair of distinct non-adjacent vertices v and u. If a graph has Ore's property, then it is Hamiltonian.- Parameters:
graph- the input graph.- Returns:
trueif the graph has Ore's property, false otherwise.- Throws:
IllegalArgumentException- if the graph is directed.- See Also:
-
isClique
Checks if the specified vertices represent a clique, meaning that the subgraph induced by them is complete.- Parameters:
graph- the input graph.vertices- an array of vertices.- Returns:
trueif the vertices form a clique,falseotherwise.- Throws:
IllegalArgumentException- if the graph is directed.InvalidVertexException- if any of the vertices is not in the graph.
-
isStableSet
Checks if the specified vertices represent a stable set, meaning that the subgraph induced by them is edgeless.- Parameters:
graph- the input graph.vertices- an array of vertices.- Returns:
trueif the vertices form a stable set,falseotherwise.- Throws:
IllegalArgumentException- if the graph is directed.InvalidVertexException- if any of the vertices is not in the graph.
-
isOverfull
Checks if a graph is overfull, meaning its size is greater than the product of its maximum degree and half of its order floored:|E| > Δ(G) |V|/2, whereΔ(G)is the maximum degree of the graph. Overfull property play a role in results concerning edge coloring.- Parameters:
graph- the input graph.- Returns:
trueif the graph is overfull,falseotherwise.
-