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 DefaultGraphType
dag()
A directed acyclic graph.static DefaultGraphType
A directed multigraph type.static DefaultGraphType
A directed pseudograph type.static DefaultGraphType
A directed simple graph type.boolean
Returnstrue
if and only if cycles are allowed in this graph.boolean
Returnstrue
if and only if multiple (parallel) edges are allowed in this graph.boolean
Returnstrue
if and only if self-loops are allowed in this graph.boolean
Returns true if all edges of the graph are directed, false otherwise.boolean
isMixed()
Returns true if the graph contain both directed and undirected edges, false otherwise.boolean
Returnstrue
if the graph is modifiable,false
otherwise.boolean
Returnstrue
if the graph is a multigraph,false
otherwise.boolean
Returnstrue
if the graph is a pseudograph,false
otherwise.boolean
isSimple()
Returnstrue
if the graph is simple,false
otherwise.boolean
Returns true if all edges of the graph are undirected, false otherwise.boolean
Returnstrue
if and only if the graph supports edge weights.static DefaultGraphType
mixed()
A mixed graph type.static DefaultGraphType
A multigraph type.static DefaultGraphType
A pseudograph type.static DefaultGraphType
simple()
A simple graph type.toString()
-
Method Details
-
isDirected
public boolean isDirected()Description copied from interface:GraphType
Returns true if all edges of the graph are directed, false otherwise.- Specified by:
isDirected
in interfaceGraphType
- Returns:
- true if all edges of the graph are directed, false otherwise
-
isUndirected
public boolean isUndirected()Description copied from interface:GraphType
Returns true if all edges of the graph are undirected, false otherwise.- Specified by:
isUndirected
in interfaceGraphType
- Returns:
- true if all edges of the graph are undirected, false otherwise
-
isMixed
public boolean isMixed()Description copied from interface:GraphType
Returns true if the graph contain both directed and undirected edges, false otherwise. -
isAllowingMultipleEdges
public boolean isAllowingMultipleEdges()Description copied from interface:GraphType
Returnstrue
if 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:
isAllowingMultipleEdges
in interfaceGraphType
- Returns:
true
if and only if multiple (parallel) edges are allowed.
-
isAllowingSelfLoops
public boolean isAllowingSelfLoops()Description copied from interface:GraphType
Returnstrue
if 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:
isAllowingSelfLoops
in interfaceGraphType
- Returns:
true
if and only if graph self-loops are allowed.
-
isWeighted
public boolean isWeighted()Description copied from interface:GraphType
Returnstrue
if and only if the graph supports edge weights.- Specified by:
isWeighted
in interfaceGraphType
- Returns:
true
if the graph supports edge weights,false
otherwise.
-
isAllowingCycles
public boolean isAllowingCycles()Description copied from interface:GraphType
Returnstrue
if and only if cycles are allowed in this graph.- Specified by:
isAllowingCycles
in interfaceGraphType
- Returns:
true
if and only if graph cycles are allowed.
-
isModifiable
public boolean isModifiable()Description copied from interface:GraphType
Returnstrue
if the graph is modifiable,false
otherwise.- Specified by:
isModifiable
in interfaceGraphType
- Returns:
true
if the graph is modifiable,false
otherwise
-
isSimple
public boolean isSimple()Description copied from interface:GraphType
Returnstrue
if the graph is simple,false
otherwise. -
isPseudograph
public boolean isPseudograph()Description copied from interface:GraphType
Returnstrue
if the graph is a pseudograph,false
otherwise.- Specified by:
isPseudograph
in interfaceGraphType
- Returns:
true
if the graph is a pseudograph,false
otherwise
-
isMultigraph
public boolean isMultigraph()Description copied from interface:GraphType
Returnstrue
if the graph is a multigraph,false
otherwise.- Specified by:
isMultigraph
in interfaceGraphType
- Returns:
true
if the graph is a multigraph,false
otherwise
-
asDirected
Description copied from interface:GraphType
Create a directed variant of the current graph type.- Specified by:
asDirected
in interfaceGraphType
- Returns:
- a directed variant of the current graph type
-
asUndirected
Description copied from interface:GraphType
Create an undirected variant of the current graph type.- Specified by:
asUndirected
in interfaceGraphType
- Returns:
- an undirected variant of the current graph type
-
asMixed
Description copied from interface:GraphType
Create a mixed variant of the current graph type. -
asUnweighted
Description copied from interface:GraphType
Create an unweighted variant of the current graph type.- Specified by:
asUnweighted
in interfaceGraphType
- Returns:
- an unweighted variant of the current graph type
-
asWeighted
Description copied from interface:GraphType
Create a weighted variant of the current graph type.- Specified by:
asWeighted
in interfaceGraphType
- Returns:
- a weighted variant of the current graph type
-
asModifiable
Description copied from interface:GraphType
Create a modifiable variant of the current graph type.- Specified by:
asModifiable
in interfaceGraphType
- Returns:
- a modifiable variant of the current graph type
-
asUnmodifiable
Description copied from interface:GraphType
Create an unmodifiable variant of the current graph type.- Specified by:
asUnmodifiable
in 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
-