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

public class ObservableGraph<V,E> extends GraphDecorator<V,E>
A decorator class for graphs which generates events
See Also:
  • Field Details

  • Constructor Details

    • ObservableGraph

      public ObservableGraph(Graph<V,E> delegate)
      Creates a new instance based on the provided delegate.
      Parameters:
      delegate - the graph on which this class operates
  • Method Details

    • addGraphEventListener

      public void addGraphEventListener(GraphEventListener<V,E> l)
      Adds l as a listener to this graph.
      Parameters:
      l - the listener to add
    • removeGraphEventListener

      public void removeGraphEventListener(GraphEventListener<V,E> l)
      Removes l as a listener to this graph.
      Parameters:
      l - the listener to remove
    • fireGraphEvent

      protected void fireGraphEvent(GraphEvent<V,E> evt)
    • addEdge

      public boolean addEdge(E edge, Collection<? extends V> vertices)
      Description copied from interface: Hypergraph
      Adds edge to this graph. Fails under the following circumstances:
      • edge is already an element of the graph
      • either edge or vertices is null
      • vertices has the wrong number of vertices for the graph type
      • vertices are already connected by another edge in this graph, and this graph does not accept parallel edges
      Specified by:
      addEdge in interface Hypergraph<V,E>
      Overrides:
      addEdge in class GraphDecorator<V,E>
      Parameters:
      edge - the edge to add
      vertices - the vertices to which the edge will be connected
      Returns:
      true if the add is successful, and false otherwise
      See Also:
    • addEdge

      public boolean addEdge(E e, V v1, V v2, EdgeType edgeType)
      Description copied from interface: Graph
      Adds edge e to this graph such that it connects vertex v1 to v2. Equivalent to addEdge(e, new Pair(v1, v2)). If this graph does not contain v1, v2, or both, implementations may choose to either silently add the vertices to the graph or throw an IllegalArgumentException. If edgeType is not legal for this graph, this method will throw IllegalArgumentException. See Hypergraph.addEdge() for a listing of possible reasons for failure.
      Specified by:
      addEdge in interface Graph<V,E>
      Overrides:
      addEdge in class GraphDecorator<V,E>
      Parameters:
      e - the edge to be added
      v1 - the first vertex to be connected
      v2 - the second vertex to be connected
      edgeType - the type to be assigned to the edge
      Returns:
      true if the add is successful, false otherwise
      See Also:
    • addEdge

      public boolean addEdge(E e, V v1, V v2)
      Description copied from interface: Graph
      Adds edge e to this graph such that it connects vertex v1 to v2. Equivalent to addEdge(e, new Pair(v1, v2)). If this graph does not contain v1, v2, or both, implementations may choose to either silently add the vertices to the graph or throw an IllegalArgumentException. If this graph assigns edge types to its edges, the edge type of e will be the default for this graph. See Hypergraph.addEdge() for a listing of possible reasons for failure.
      Specified by:
      addEdge in interface Graph<V,E>
      Overrides:
      addEdge in class GraphDecorator<V,E>
      Parameters:
      e - the edge to be added
      v1 - the first vertex to be connected
      v2 - the second vertex to be connected
      Returns:
      true if the add is successful, false otherwise
      See Also:
    • addVertex

      public boolean addVertex(V vertex)
      Description copied from interface: Hypergraph
      Adds vertex to this graph. Fails if vertex is null or already in the graph.
      Specified by:
      addVertex in interface Hypergraph<V,E>
      Overrides:
      addVertex in class GraphDecorator<V,E>
      Parameters:
      vertex - the vertex to add
      Returns:
      true if the add is successful, and false otherwise
      See Also:
    • removeEdge

      public boolean removeEdge(E edge)
      Description copied from interface: Hypergraph
      Removes edge from this graph. Fails if edge is null, or is otherwise not an element of this graph.
      Specified by:
      removeEdge in interface Hypergraph<V,E>
      Overrides:
      removeEdge in class GraphDecorator<V,E>
      Parameters:
      edge - the edge to remove
      Returns:
      true if the removal is successful, false otherwise
      See Also:
    • removeVertex

      public boolean removeVertex(V vertex)
      Description copied from interface: Hypergraph
      Removes vertex from this graph. As a side effect, removes any edges e incident to vertex if the removal of vertex would cause e 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 graph
      • vertex is null
      Specified by:
      removeVertex in interface Hypergraph<V,E>
      Overrides:
      removeVertex in class GraphDecorator<V,E>
      Parameters:
      vertex - the vertex to remove
      Returns:
      true if the removal is successful, false otherwise
      See Also: