Package edu.uci.ics.jung.graph
Class ObservableGraph<V,E>
java.lang.Object
edu.uci.ics.jung.graph.GraphDecorator<V,E>
edu.uci.ics.jung.graph.ObservableGraph<V,E>
- All Implemented Interfaces:
Graph<V,
,E> Hypergraph<V,
,E> Serializable
A decorator class for graphs which generates events
- See Also:
-
Field Summary
FieldsFields inherited from class edu.uci.ics.jung.graph.GraphDecorator
delegate
-
Constructor Summary
ConstructorsConstructorDescriptionObservableGraph
(Graph<V, E> delegate) Creates a new instance based on the provideddelegate
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addEdge
(E edge, Collection<? extends V> vertices) Addsedge
to this graph.boolean
Adds edgee
to this graph such that it connects vertexv1
tov2
.boolean
Adds edgee
to this graph such that it connects vertexv1
tov2
.void
Addsl
as a listener to this graph.boolean
Addsvertex
to this graph.protected void
fireGraphEvent
(GraphEvent<V, E> evt) boolean
removeEdge
(E edge) Removesedge
from this graph.void
Removesl
as a listener to this graph.boolean
removeVertex
(V vertex) Removesvertex
from this graph.Methods inherited from class edu.uci.ics.jung.graph.GraphDecorator
addEdge, containsEdge, containsVertex, degree, findEdge, findEdgeSet, getDefaultEdgeType, getDest, getEdgeCount, getEdgeCount, getEdges, getEdges, getEdgeType, getEndpoints, getIncidentCount, getIncidentEdges, getIncidentVertices, getInEdges, getNeighborCount, getNeighbors, getOpposite, getOutEdges, getPredecessorCount, getPredecessors, getSource, getSuccessorCount, getSuccessors, getVertexCount, getVertices, inDegree, isDest, isIncident, isNeighbor, isPredecessor, isSource, isSuccessor, outDegree
-
Field Details
-
listenerList
List<GraphEventListener<V,E>> listenerList
-
-
Constructor Details
-
ObservableGraph
Creates a new instance based on the provideddelegate
.- Parameters:
delegate
- the graph on which this class operates
-
-
Method Details
-
addGraphEventListener
Addsl
as a listener to this graph.- Parameters:
l
- the listener to add
-
removeGraphEventListener
Removesl
as a listener to this graph.- Parameters:
l
- the listener to remove
-
fireGraphEvent
-
addEdge
Description copied from interface:Hypergraph
Addsedge
to this graph. Fails under the following circumstances:edge
is already an element of the graph- either
edge
orvertices
isnull
vertices
has the wrong number of vertices for the graph typevertices
are already connected by another edge in this graph, and this graph does not accept parallel edges
- Specified by:
addEdge
in interfaceHypergraph<V,
E> - Overrides:
addEdge
in classGraphDecorator<V,
E> - Parameters:
edge
- the edge to addvertices
- the vertices to which the edge will be connected- Returns:
true
if the add is successful, andfalse
otherwise- See Also:
-
addEdge
Description copied from interface:Graph
Adds edgee
to this graph such that it connects vertexv1
tov2
. Equivalent toaddEdge(e, new Pair(v1, v2))
. If this graph does not containv1
,v2
, or both, implementations may choose to either silently add the vertices to the graph or throw anIllegalArgumentException
. IfedgeType
is not legal for this graph, this method will throwIllegalArgumentException
. SeeHypergraph.addEdge()
for a listing of possible reasons for failure.- Specified by:
addEdge
in interfaceGraph<V,
E> - Overrides:
addEdge
in classGraphDecorator<V,
E> - Parameters:
e
- the edge to be addedv1
- the first vertex to be connectedv2
- the second vertex to be connectededgeType
- the type to be assigned to the edge- Returns:
true
if the add is successful,false
otherwise- See Also:
-
addEdge
Description copied from interface:Graph
Adds edgee
to this graph such that it connects vertexv1
tov2
. Equivalent toaddEdge(e, new Pair(v1, v2))
. If this graph does not containv1
,v2
, or both, implementations may choose to either silently add the vertices to the graph or throw anIllegalArgumentException
. If this graph assigns edge types to its edges, the edge type ofe
will be the default for this graph. SeeHypergraph.addEdge()
for a listing of possible reasons for failure. -
addVertex
Description copied from interface:Hypergraph
Addsvertex
to this graph. Fails ifvertex
is null or already in the graph.- Specified by:
addVertex
in interfaceHypergraph<V,
E> - Overrides:
addVertex
in classGraphDecorator<V,
E> - Parameters:
vertex
- the vertex to add- Returns:
true
if the add is successful, andfalse
otherwise- See Also:
-
removeEdge
Description copied from interface:Hypergraph
Removesedge
from this graph. Fails ifedge
is null, or is otherwise not an element of this graph.- Specified by:
removeEdge
in interfaceHypergraph<V,
E> - Overrides:
removeEdge
in classGraphDecorator<V,
E> - Parameters:
edge
- the edge to remove- Returns:
true
if the removal is successful,false
otherwise- See Also:
-
removeVertex
Description copied from interface:Hypergraph
Removesvertex
from this graph. As a side effect, removes any edgese
incident tovertex
if the removal ofvertex
would causee
to be incident to an illegal number of vertices. (Thus, for example, incident hyperedges are not removed, but incident edges--which must be connected to a vertex at both endpoints--are removed.)Fails under the following circumstances:
vertex
is not an element of this graphvertex
isnull
- Specified by:
removeVertex
in interfaceHypergraph<V,
E> - Overrides:
removeVertex
in classGraphDecorator<V,
E> - Parameters:
vertex
- the vertex to remove- Returns:
true
if the removal is successful,false
otherwise- See Also:
-