Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.uci.ics.jung.utils
Class SubsetManager

    java.lang.Object
      edu.uci.ics.jung.utils.SubsetManager

All Implemented Interfaces:
  EventListener, GraphEventListener

public class SubsetManager
extends 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

Field Summary
`protected Map` | `edgeMap`
`protected ArchetypeGraph` | `g` The graph for which this instance manages subsets.
`protected Map` | `vertexMap` Map specifications (in the form of Predicates) to the corresponding subsets.

Constructor Summary
`protected` | `SubsetManager(ArchetypeGraph g)` Creates a `SubsetManager`, adds it to the specified graph's user data repository, and adds itself as a listener to the graph's vertex and edge addition and removal events, so that the subsets' memberships can be maintained.

Method Summary
`boolean` | `addEdgeSubset(Predicate p)` Creates an edge subset based on `p`.
`boolean` | `addVertexSubset(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.
`protected Map` | `getEdgeMap()`
`Set` | `getEdges(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.
`protected Map` | `getVertexMap()`
`Set` | `getVertices(Predicate p)` Returns the vertex subset, if any, which this instance has defined based on `p`.
`void` | `removeEdgeSubset(Predicate p)` Removes the edge subset based on `p`.
`void` | `removeVertexSubset(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
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### vertexMap

    protected Map vertexMap

  Map specifications (in the form of Predicates) to the corresponding subsets. These are only instantiated if a subset of the appropriate type is created.

### edgeMap

    protected Map edgeMap

### g

    protected ArchetypeGraph g

  The graph for which this instance manages subsets.

Constructor Detail

### SubsetManager

    protected SubsetManager(ArchetypeGraph g)

  Creates a `SubsetManager`, adds it to the specified graph's user data repository, and adds itself as a listener to the graph's vertex and edge addition and removal events, so that the subsets' memberships can be maintained.

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 Set getVertices(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 Set getEdges(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(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(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(Predicate p)

  Removes the vertex subset based on `p`.

  Parameters:
    `p` - the predicate defining the subset

### removeEdgeSubset

    public void removeEdgeSubset(Predicate p)

  Removes the edge subset based on `p`.

  Parameters:
    `p` - the predicate defining the subset

### getVertexMap

    protected Map getVertexMap()

### getEdgeMap

    protected Map getEdgeMap()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD