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.graph.filters
Interface Filter

All Known Subinterfaces:
  EfficientFilter, LevelFilter

All Known Implementing Classes:
  AlphabeticVertexFilter, GeneralEdgeAcceptFilter, GeneralVertexAcceptFilter, KNeighborhoodFilter, SerialFilter, TrivialFilter, WeightedEdgeGraphFilter

public interface Filter

A `Filter` returns a subgraph of a `Graph`, in the form of an `UnsassembledGraph`. That `UnsassembledGraph` can then be turned into a `Graph` with a call to `assemble()`. A `Filter`, then, selects the subset of vertices and edges and from them creates an `UnassembledGraph` (presumably, with one of its two constructors.)

An `UnsassembledGraph` represents all the vertices (and at least all the edges) of a `Graph` that pass the subset. However, they have not been "assembled" into something that fulfills the `Graph` contract. (In particular, the `Vertices` and `Edges` that make up the `UnassembledGraph` still report, through `getGraph()`, that they are members of the original, and they still are connected to all the original edges.

After the call to `assemble`, the new `Graph` is valid , following the Graph contract fully.

## Sample code

This code is taken from the JUnit tests for the filter code, with minor modifications. It demonstrates how to walk through the filter process.

     Graph g = TestGraphs.createTestGraph( true );
     // creates a graph.
     EdgeWeightLabeller ewl = EdgeWeightLabeller.getLabeller( g );
     // links each edge to a weight.
     WeightedEdgeGraphFilter wgf = new WeightedEdgeGraphFilter( 0, ewl );
     // creates a filter based on this weight

     wgf.setValue(3);
     // sets the threshold at 3.
     // at this point, the Filter is ready to block any edges with a weight less than 3.

     UnassembledGraph ug = wgf.filter(g);
     // this UnassembledGraph contains all edges of weight greater than three, and all vertices in g

     Graph sub_g = ug.assemble();

At the end of this code, the new graph `sub_g` contains a copy of some edges, and all nodes, of `g`. From here, we can treat it as a `Graph`. Note that calls like `getEquivalentVertex( Graph )` will do the right thing on the vertices of `sub_g` and point back to `g`.

In addition, we now have access to the ``GraphAssemblyRecord`` that corresponds to the graph.

     	GraphAssemblyRecord gar = getAssemblyRecord( sub_g );
      String filterName = gar.getName();

Author:
  danyelf
See Also:
  `EfficientFilter`

Method Summary
`UnassembledGraph` | `filter(Graph g)` Filters a graph by returning an `UnassembledGraph` consisting of nodes and edges that pass the filter.
`String` | `getName()` Gets a name that describes this filter.

Method Detail

### filter

    public UnassembledGraph filter(Graph g)

  Filters a graph by returning an `UnassembledGraph` consisting of nodes and edges that pass the filter.

  Parameters:
    `g` - An input graph to be filtered.
  Returns:
    an `UnassembledGraph` that contains the subset of vertices and edges from `g` pass the filter.

### getName

    public String getName()

  Gets a name that describes this filter. It is used by the auditing methods in ``GraphAssemblyRecord``

  Returns:
    A string that describes the filter.

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