java.lang.Object
org.jgrapht.graph.DefaultGraphType
- All Implemented Interfaces:
Serializable,GraphType
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:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionCreate a directed variant of the current graph type.asMixed()Create a mixed variant of the current graph type.Create a modifiable variant of the current graph type.Create an undirected variant of the current graph type.Create an unmodifiable variant of the current graph type.Create an unweighted variant of the current graph type.Create a weighted variant of the current graph type.static DefaultGraphTypedag()A directed acyclic graph.static DefaultGraphTypeA directed multigraph type.static DefaultGraphTypeA directed pseudograph type.static DefaultGraphTypeA directed simple graph type.booleanReturnstrueif and only if cycles are allowed in this graph.booleanReturnstrueif and only if multiple (parallel) edges are allowed in this graph.booleanReturnstrueif and only if self-loops are allowed in this graph.booleanReturns 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.booleanReturnstrueif the graph is modifiable,falseotherwise.booleanReturnstrueif the graph is a multigraph,falseotherwise.booleanReturnstrueif the graph is a pseudograph,falseotherwise.booleanisSimple()Returnstrueif the graph is simple,falseotherwise.booleanReturns true if all edges of the graph are undirected, false otherwise.booleanReturnstrueif and only if the graph supports edge weights.static DefaultGraphTypemixed()A mixed graph type.static DefaultGraphTypeA multigraph type.static DefaultGraphTypeA pseudograph type.static DefaultGraphTypesimple()A simple graph type.toString()
-
Method Details
-
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
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
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
Description copied from interface:GraphTypeCreate a mixed variant of the current graph type. -
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
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
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
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
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
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
A pseudograph type. A non-simple undirected graph in which both graph self-loops and multiple edges are permitted.- Returns:
- a pseudograph type
-
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
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
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
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
A directed acyclic graph.- Returns:
- a directed acyclic graph type
-
toString
-