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