org._3pq.jgrapht.graph
Class AbstractBaseGraph
- Cloneable, Graph, Serializable
public abstract class AbstractBaseGraph
implements Graph, Cloneable, Serializable
The most general implementation of the
Graph
interface. Its subclasses add various restrictions to get more specific
graphs. The decision whether it is directed or undirected is decided at
construction time and cannot be later modified (see constructor for
details).
This graph implementation guarantees deterministic vertex and edge set
ordering (via
LinkedHashMap
and
LinkedHashSet
).
AbstractBaseGraph
public AbstractBaseGraph(EdgeFactory ef,
boolean allowMultipleEdges,
boolean allowLoops)
Construct a new pseudograph. The pseudograph can either be directed or
undirected, depending on the specified edge factory. A sample edge is
created using the edge factory to see if the factory is compatible with
this class of graph. For example, if this graph is a
DirectedGraph
the edge factory must produce
DirectedEdge
s. If this is not the case, an
IllegalArgumentException
is thrown.
ef
- the edge factory of the new graph.allowMultipleEdges
- whether to allow multiple edges or not.allowLoops
- whether to allow edges that are self-loops or not.
addEdge
public Edge addEdge(Object sourceVertex,
Object targetVertex)
- addEdge in interface Graph
addVertex
public boolean addVertex(Object v)
- addVertex in interface Graph
clone
public Object clone()
Returns a shallow copy of this graph instance. Neither edges nor
vertices are cloned.
- a shallow copy of this set.
degreeOf
public int degreeOf(Object vertex)
org._3pq.jgrapht.UndirectedGraph.degreeOf(java.lang.Object)
edgesOf
public List edgesOf(Object vertex)
- edgesOf in interface Graph
getAllEdges
public List getAllEdges(Object sourceVertex,
Object targetVertex)
- getAllEdges in interface Graph
getEdge
public Edge getEdge(Object sourceVertex,
Object targetVertex)
- getEdge in interface Graph
inDegreeOf
public int inDegreeOf(Object vertex)
org._3pq.jgrapht.DirectedGraph.inDegreeOf(java.lang.Object)
incomingEdgesOf
public List incomingEdgesOf(Object vertex)
org._3pq.jgrapht.DirectedGraph.incomingEdgesOf(java.lang.Object)
isAllowingLoops
public boolean isAllowingLoops()
Returns 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.
true
if and only if graph loops are allowed.
isAllowingMultipleEdges
public boolean isAllowingMultipleEdges()
Returns true
if and only if multiple 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.
true
if and only if multiple edges are allowed.
outDegreeOf
public int outDegreeOf(Object vertex)
org._3pq.jgrapht.DirectedGraph.outDegreeOf(java.lang.Object)
outgoingEdgesOf
public List outgoingEdgesOf(Object vertex)
org._3pq.jgrapht.DirectedGraph.outgoingEdgesOf(java.lang.Object)
removeEdge
public Edge removeEdge(Object sourceVertex,
Object targetVertex)
- removeEdge in interface Graph
setEdgeListFactory
public void setEdgeListFactory(EdgeListFactory edgeListFactory)
Set the
EdgeListFactory
to use for this graph. Initially, a
graph is created with a default implementation which always supplies an
java.util.ArrayList
with capacity 1.
edgeListFactory
- factory to use for subsequently created edge
lists (this call has no effect on existing edge lists)