Package org.jgrapht.graph
Class DefaultGraphType
- java.lang.Object
-
- org.jgrapht.graph.DefaultGraphType
-
- All Implemented Interfaces:
java.io.Serializable,GraphType
public class DefaultGraphType extends java.lang.Object implements GraphType, java.io.Serializable
Default implementation of the graph type.The graph type describes various properties of a graph such as whether it is directed, undirected or mixed, whether it contain self-loops (a self-loop is an edge where the source vertex is the same as the target vertex), whether it contain multiple (parallel) edges (multiple edges which connect the same pair of vertices) and whether it is weighted or not.
The type of a graph can be queried on runtime using method
Graph.getType(). This way, for example, an algorithm can have different behavior based on whether the input graph is directed or undirected, etc.- Author:
- Dimitrios Michail
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDefaultGraphType.BuilderA builder forDefaultGraphType.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description GraphTypeasDirected()Create a directed variant of the current graph type.GraphTypeasMixed()Create a mixed variant of the current graph type.GraphTypeasModifiable()Create a modifiable variant of the current graph type.GraphTypeasUndirected()Create an undirected variant of the current graph type.GraphTypeasUnmodifiable()Create an unmodifiable variant of the current graph type.GraphTypeasUnweighted()Create an unweighted variant of the current graph type.GraphTypeasWeighted()Create a weighted variant of the current graph type.static DefaultGraphTypedag()A directed acyclic graph.static DefaultGraphTypedirectedMultigraph()A directed multigraph type.static DefaultGraphTypedirectedPseudograph()A directed pseudograph type.static DefaultGraphTypedirectedSimple()A directed simple graph type.booleanisAllowingCycles()Returnstrueif and only if cycles are allowed in this graph.booleanisAllowingMultipleEdges()Returnstrueif and only if multiple (parallel) edges are allowed in this graph.booleanisAllowingSelfLoops()Returnstrueif and only if self-loops are allowed in this graph.booleanisDirected()Returns true if all edges of the graph are directed, false otherwise.booleanisMixed()Returns true if the graph contain both directed and undirected edges, false otherwise.booleanisModifiable()Returnstrueif the graph is modifiable,falseotherwise.booleanisMultigraph()Returnstrueif the graph is a multigraph,falseotherwise.booleanisPseudograph()Returnstrueif the graph is a pseudograph,falseotherwise.booleanisSimple()Returnstrueif the graph is simple,falseotherwise.booleanisUndirected()Returns true if all edges of the graph are undirected, false otherwise.booleanisWeighted()Returnstrueif and only if the graph supports edge weights.static DefaultGraphTypemixed()A mixed graph type.static DefaultGraphTypemultigraph()A multigraph type.static DefaultGraphTypepseudograph()A pseudograph type.static DefaultGraphTypesimple()A simple graph type.java.lang.StringtoString()
-
-
-
Method Detail
-
isDirected
public boolean isDirected()
Description copied from interface:GraphTypeReturns true if all edges of the graph are directed, false otherwise.- Specified by:
isDirectedin interfaceGraphType- Returns:
- true if all edges of the graph are directed, false otherwise
-
isUndirected
public boolean isUndirected()
Description copied from interface:GraphTypeReturns true if all edges of the graph are undirected, false otherwise.- Specified by:
isUndirectedin interfaceGraphType- Returns:
- true if all edges of the graph are undirected, false otherwise
-
isMixed
public boolean isMixed()
Description copied from interface:GraphTypeReturns true if the graph contain both directed and undirected edges, false otherwise.
-
isAllowingMultipleEdges
public boolean isAllowingMultipleEdges()
Description copied from interface:GraphTypeReturnstrueif and only if multiple (parallel) edges are allowed in this graph. The meaning of multiple edges is that there can be many edges going from vertex v1 to vertex v2.- Specified by:
isAllowingMultipleEdgesin interfaceGraphType- Returns:
trueif and only if multiple (parallel) edges are allowed.
-
isAllowingSelfLoops
public boolean isAllowingSelfLoops()
Description copied from interface:GraphTypeReturnstrueif and only if self-loops are allowed in this graph. A self loop is an edge that its source and target vertices are the same.- Specified by:
isAllowingSelfLoopsin interfaceGraphType- Returns:
trueif and only if graph self-loops are allowed.
-
isWeighted
public boolean isWeighted()
Description copied from interface:GraphTypeReturnstrueif and only if the graph supports edge weights.- Specified by:
isWeightedin interfaceGraphType- Returns:
trueif the graph supports edge weights,falseotherwise.
-
isAllowingCycles
public boolean isAllowingCycles()
Description copied from interface:GraphTypeReturnstrueif and only if cycles are allowed in this graph.- Specified by:
isAllowingCyclesin interfaceGraphType- Returns:
trueif and only if graph cycles are allowed.
-
isModifiable
public boolean isModifiable()
Description copied from interface:GraphTypeReturnstrueif the graph is modifiable,falseotherwise.- Specified by:
isModifiablein interfaceGraphType- Returns:
trueif the graph is modifiable,falseotherwise
-
isSimple
public boolean isSimple()
Description copied from interface:GraphTypeReturnstrueif the graph is simple,falseotherwise.
-
isPseudograph
public boolean isPseudograph()
Description copied from interface:GraphTypeReturnstrueif the graph is a pseudograph,falseotherwise.- Specified by:
isPseudographin interfaceGraphType- Returns:
trueif the graph is a pseudograph,falseotherwise
-
isMultigraph
public boolean isMultigraph()
Description copied from interface:GraphTypeReturnstrueif the graph is a multigraph,falseotherwise.- Specified by:
isMultigraphin interfaceGraphType- Returns:
trueif the graph is a multigraph,falseotherwise
-
asDirected
public GraphType asDirected()
Description copied from interface:GraphTypeCreate a directed variant of the current graph type.- Specified by:
asDirectedin interfaceGraphType- Returns:
- a directed variant of the current graph type
-
asUndirected
public GraphType asUndirected()
Description copied from interface:GraphTypeCreate an undirected variant of the current graph type.- Specified by:
asUndirectedin interfaceGraphType- Returns:
- an undirected variant of the current graph type
-
asMixed
public GraphType asMixed()
Description copied from interface:GraphTypeCreate a mixed variant of the current graph type.
-
asUnweighted
public GraphType asUnweighted()
Description copied from interface:GraphTypeCreate an unweighted variant of the current graph type.- Specified by:
asUnweightedin interfaceGraphType- Returns:
- an unweighted variant of the current graph type
-
asWeighted
public GraphType asWeighted()
Description copied from interface:GraphTypeCreate a weighted variant of the current graph type.- Specified by:
asWeightedin interfaceGraphType- Returns:
- a weighted variant of the current graph type
-
asModifiable
public GraphType asModifiable()
Description copied from interface:GraphTypeCreate a modifiable variant of the current graph type.- Specified by:
asModifiablein interfaceGraphType- Returns:
- a modifiable variant of the current graph type
-
asUnmodifiable
public GraphType asUnmodifiable()
Description copied from interface:GraphTypeCreate an unmodifiable variant of the current graph type.- Specified by:
asUnmodifiablein interfaceGraphType- Returns:
- a unmodifiable variant of the current graph type
-
simple
public static DefaultGraphType simple()
A simple graph type. An undirected graph for which at most one edge connects any two vertices, and self-loops are not permitted.- Returns:
- a simple graph type
-
multigraph
public static DefaultGraphType multigraph()
A multigraph type. A non-simple undirected graph in which no self-loops are permitted, but multiple edges between any two vertices are.- Returns:
- a multigraph type
-
pseudograph
public static DefaultGraphType pseudograph()
A pseudograph type. A non-simple undirected graph in which both graph self-loops and multiple edges are permitted.- Returns:
- a pseudograph type
-
directedSimple
public static DefaultGraphType directedSimple()
A directed simple graph type. An undirected graph for which at most one edge connects any two vertices, and self-loops are not permitted.- Returns:
- a directed simple graph type
-
directedMultigraph
public static DefaultGraphType directedMultigraph()
A directed multigraph type. A non-simple undirected graph in which no self-loops are permitted, but multiple edges between any two vertices are.- Returns:
- a directed multigraph type
-
directedPseudograph
public static DefaultGraphType directedPseudograph()
A directed pseudograph type. A non-simple undirected graph in which both graph self-loops and multiple edges are permitted.- Returns:
- a directed pseudograph type
-
mixed
public static DefaultGraphType mixed()
A mixed graph type. A graph having a set of undirected and a set of directed edges, which may contain self-loops and multiple edges are permitted.- Returns:
- a mixed graph type
-
dag
public static DefaultGraphType dag()
A directed acyclic graph.- Returns:
- a directed acyclic graph type
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-