edu.uci.ics.jung.utils
Class SubsetManager

java.lang.Object
  extended byedu.uci.ics.jung.utils.SubsetManager
All Implemented Interfaces:
java.util.EventListener, GraphEventListener

public class SubsetManager
extends java.lang.Object
implements GraphEventListener

A class which allows users to create and maintain Predicate-specified vertex and edge subsets. The subsets are automatically maintained as vertices and edges are added to, and removed from, the constructor-specified graph.

A subset is created by providing a Predicate; those graph elements that pass the predicate are added to the subset.

Author:
Joshua O'Madadhain

Method Summary
 boolean addEdgeSubset(org.apache.commons.collections.Predicate p)
          Creates an edge subset based on p.
 boolean addVertexSubset(org.apache.commons.collections.Predicate p)
          Creates a vertex subset based on p.
 void edgeAdded(GraphEvent event)
          Adds the edge whose event this is to all appropriate subsets.
 void edgeRemoved(GraphEvent event)
          Removes the edge whose event this is from all appropriate subsets.
 java.util.Set getEdges(org.apache.commons.collections.Predicate p)
          Returns the edge subset, if any, which this instance has defined based on p.
static SubsetManager getInstance(ArchetypeGraph g)
          Gets this graph's SubsetManager, creating it if necessary.
 java.util.Set getVertices(org.apache.commons.collections.Predicate p)
          Returns the vertex subset, if any, which this instance has defined based on p.
 void removeEdgeSubset(org.apache.commons.collections.Predicate p)
          Removes the edge subset based on p.
 void removeVertexSubset(org.apache.commons.collections.Predicate p)
          Removes the vertex subset based on p.
 void vertexAdded(GraphEvent event)
          Adds the vertex whose event this is to all appropriate subsets.
 void vertexRemoved(GraphEvent event)
          Removes the vertex whose event this is from all appropriate subsets.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static SubsetManager getInstance(ArchetypeGraph g)
Gets this graph's SubsetManager, creating it if necessary.

Parameters:
g - the graph whose subset manager is requested

vertexAdded

public void vertexAdded(GraphEvent event)
Adds the vertex whose event this is to all appropriate subsets.

Specified by:
vertexAdded in interface GraphEventListener

vertexRemoved

public void vertexRemoved(GraphEvent event)
Removes the vertex whose event this is from all appropriate subsets.

Specified by:
vertexRemoved in interface GraphEventListener

edgeAdded

public void edgeAdded(GraphEvent event)
Adds the edge whose event this is to all appropriate subsets.

Specified by:
edgeAdded in interface GraphEventListener

edgeRemoved

public void edgeRemoved(GraphEvent event)
Removes the edge whose event this is from all appropriate subsets.

Specified by:
edgeRemoved in interface GraphEventListener

getVertices

public java.util.Set getVertices(org.apache.commons.collections.Predicate p)
Returns the vertex subset, if any, which this instance has defined based on p. If this instance has defined no such subset, returns null.

Parameters:
p - the predicate which may define a subset

getEdges

public java.util.Set getEdges(org.apache.commons.collections.Predicate p)
Returns the edge subset, if any, which this instance has defined based on p. If this instance has defined no such subset, returns null.

Parameters:
p - the predicate which may define a subset

addVertexSubset

public boolean addVertexSubset(org.apache.commons.collections.Predicate p)
Creates a vertex subset based on p.

Parameters:
p - the predicate defining the subset
Returns:
true if a subset was created; false if the subset already existed

addEdgeSubset

public boolean addEdgeSubset(org.apache.commons.collections.Predicate p)
Creates an edge subset based on p.

Parameters:
p - the predicate defining the subset
Returns:
true if a subset was created; false if the subset already existed

removeVertexSubset

public void removeVertexSubset(org.apache.commons.collections.Predicate p)
Removes the vertex subset based on p.

Parameters:
p - the predicate defining the subset

removeEdgeSubset

public void removeEdgeSubset(org.apache.commons.collections.Predicate p)
Removes the edge subset based on p.

Parameters:
p - the predicate defining the subset