public class DefaultGraphType extends Object implements GraphType, Serializable
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.
Modifier and Type | Class and Description |
---|---|
static class |
DefaultGraphType.Builder
A builder for
DefaultGraphType . |
Modifier and Type | Method and Description |
---|---|
GraphType |
asDirected()
Create a directed variant of the current graph type.
|
GraphType |
asMixed()
Create a mixed variant of the current graph type.
|
GraphType |
asModifiable()
Create a modifiable variant of the current graph type.
|
GraphType |
asUndirected()
Create an undirected variant of the current graph type.
|
GraphType |
asUnmodifiable()
Create an unmodifiable variant of the current graph type.
|
GraphType |
asUnweighted()
Create an unweighted variant of the current graph type.
|
GraphType |
asWeighted()
Create a weighted variant of the current graph type.
|
static DefaultGraphType |
dag()
A directed acyclic graph.
|
static DefaultGraphType |
directedMultigraph()
A directed multigraph type.
|
static DefaultGraphType |
directedPseudograph()
A directed pseudograph type.
|
static DefaultGraphType |
directedSimple()
A directed simple graph type.
|
boolean |
isAllowingCycles()
Returns
true if and only if cycles are allowed in this graph. |
boolean |
isAllowingMultipleEdges()
Returns
true if and only if multiple (parallel) edges are allowed in this graph. |
boolean |
isAllowingSelfLoops()
Returns
true if and only if self-loops are allowed in this graph. |
boolean |
isDirected()
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 |
isModifiable()
Returns
true if the graph is modifiable, false otherwise. |
boolean |
isMultigraph()
Returns
true if the graph is a multigraph, false otherwise. |
boolean |
isPseudograph()
Returns
true if the graph is a pseudograph, false otherwise. |
boolean |
isSimple()
Returns
true if the graph is simple, false otherwise. |
boolean |
isUndirected()
Returns true if all edges of the graph are undirected, false otherwise.
|
boolean |
isWeighted()
Returns
true if and only if the graph supports edge weights. |
static DefaultGraphType |
mixed()
A mixed graph type.
|
static DefaultGraphType |
multigraph()
A multigraph type.
|
static DefaultGraphType |
pseudograph()
A pseudograph type.
|
static DefaultGraphType |
simple()
A simple graph type.
|
String |
toString() |
public boolean isDirected()
GraphType
isDirected
in interface GraphType
public boolean isUndirected()
GraphType
isUndirected
in interface GraphType
public boolean isMixed()
GraphType
public boolean isAllowingMultipleEdges()
GraphType
true
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.isAllowingMultipleEdges
in interface GraphType
true
if and only if multiple (parallel) edges are allowed.public boolean isAllowingSelfLoops()
GraphType
true
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.isAllowingSelfLoops
in interface GraphType
true
if and only if graph self-loops are allowed.public boolean isWeighted()
GraphType
true
if and only if the graph supports edge weights.isWeighted
in interface GraphType
true
if the graph supports edge weights, false
otherwise.public boolean isAllowingCycles()
GraphType
true
if and only if cycles are allowed in this graph.isAllowingCycles
in interface GraphType
true
if and only if graph cycles are allowed.public boolean isModifiable()
GraphType
true
if the graph is modifiable, false
otherwise.isModifiable
in interface GraphType
true
if the graph is modifiable, false
otherwisepublic boolean isSimple()
GraphType
true
if the graph is simple, false
otherwise.public boolean isPseudograph()
GraphType
true
if the graph is a pseudograph, false
otherwise.isPseudograph
in interface GraphType
true
if the graph is a pseudograph, false
otherwisepublic boolean isMultigraph()
GraphType
true
if the graph is a multigraph, false
otherwise.isMultigraph
in interface GraphType
true
if the graph is a multigraph, false
otherwisepublic GraphType asDirected()
GraphType
asDirected
in interface GraphType
public GraphType asUndirected()
GraphType
asUndirected
in interface GraphType
public GraphType asMixed()
GraphType
public GraphType asUnweighted()
GraphType
asUnweighted
in interface GraphType
public GraphType asWeighted()
GraphType
asWeighted
in interface GraphType
public GraphType asModifiable()
GraphType
asModifiable
in interface GraphType
public GraphType asUnmodifiable()
GraphType
asUnmodifiable
in interface GraphType
public static DefaultGraphType simple()
public static DefaultGraphType multigraph()
public static DefaultGraphType pseudograph()
public static DefaultGraphType directedSimple()
public static DefaultGraphType directedMultigraph()
public static DefaultGraphType directedPseudograph()
public static DefaultGraphType mixed()
public static DefaultGraphType dag()
Copyright © 2019. All rights reserved.