org.apache.tinkerpop.gremlin.process.computer

## Class GraphFilter

- java.lang.Object
- - org.apache.tinkerpop.gremlin.process.computer.GraphFilter

- All Implemented Interfaces:
    Serializable, Cloneable

      public final class GraphFilter
      extends Object
      implements Cloneable, Serializable

  GraphFilter is used by `GraphComputer` implementations to prune the source graph data being loaded into the OLAP system. There are two types of filters: a `Vertex` filter and an `Edge` filter. The vertex filter is a `Traversal` that can only check the id, label, and properties of the vertex. The edge filter is a `Traversal` that starts at the vertex are emits all legal incident edges. If no vertex filter is provided, then no vertices are filtered. If no edge filter is provided, then no edges are filtered. The use of a GraphFilter can greatly reduce the amount of data processed by the `GraphComputer`. For instance, for `g.V().count()`, there is no reason to load edges, and thus, the edge filter can be `bothE().limit(0)`.
  Author:
    Marko A. Rodriguez (http://markorodriguez.com)
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `GraphFilter.Legal` A enum denoting whether a particular result will be allowed or not.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GraphFilter()`
    `GraphFilter(Computer computer)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `GraphFilter.Legal` | `checkEdgeLegality(Direction direction)` Get the legality of a particular edge direction.
    `GraphFilter.Legal` | `checkEdgeLegality(Direction direction, String label)` Get the legality of a particular edge direction and label.
    `GraphFilter` | `clone()`
    `boolean` | `equals(Object object)`
    `Traversal.Admin<Vertex,Edge>` | `getEdgeFilter()` Get the edge filter associated with this graph filter.
    `Set<String>` | `getLegallyPositiveEdgeLabels(Direction direction)` For a particular edge directionality, get all the `GraphFilter.Legal.YES` or `GraphFilter.Legal.MAYBE` edge labels.
    `Traversal.Admin<Vertex,Vertex>` | `getVertexFilter()` Get the vertex filter associated with this graph filter.
    `boolean` | `hasEdgeFilter()` Whether an edge filter has been defined.
    `boolean` | `hasFilter()` Whether filters have been defined.
    `int` | `hashCode()`
    `boolean` | `hasVertexFilter()` Whether a vertex filter has been defined.
    `Iterator<Edge>` | `legalEdges(Vertex vertex)` Returns an iterator of legal edges incident to the provided vertex.
    `boolean` | `legalVertex(Vertex vertex)` Returns true if the provided vertex meets the vertex-filter criteria.
    `void` | `setEdgeFilter(Traversal<Vertex,Edge> edgeFilter)` Set the filter for selecting edges from the source graph.
    `void` | `setVertexFilter(Traversal<Vertex,Vertex> vertexFilter)` Set the filter for selecting vertices from the source graph.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### GraphFilter

          public GraphFilter()

    - #### GraphFilter

          public GraphFilter(Computer computer)

  - ### Method Detail

    - #### setVertexFilter

          public void setVertexFilter(Traversal<Vertex,Vertex> vertexFilter)

      Set the filter for selecting vertices from the source graph. The vertex filter can only access the vertex, its properties, and its properties properties. Vertex filters can not access the incident edges of the vertex.
      Parameters:
        `vertexFilter` - The `Traversal` that will either let the vertex pass or not.

    - #### setEdgeFilter

          public void setEdgeFilter(Traversal<Vertex,Edge> edgeFilter)

      Set the filter for selecting edges from the source graph. The edge filter can only access the local star graph (not adjacent vertices).
      Parameters:
        `edgeFilter` - The `Traversal` that will generate the legal incident edges of the vertex.

    - #### legalVertex

          public boolean legalVertex(Vertex vertex)

      Returns true if the provided vertex meets the vertex-filter criteria. If no vertex filter is provided, then the vertex is considered legal.
      Parameters:
        `vertex` - the vertex to test for legality
      Returns:
        whether the vertex is `GraphFilter.Legal.YES`.

    - #### legalEdges

          public Iterator<Edge> legalEdges(Vertex vertex)

      Returns an iterator of legal edges incident to the provided vertex. If no edge filter is provided, then all incident edges are returned.
      Parameters:
        `vertex` - the vertex whose legal edges are to be access.
      Returns:
        an iterator of edges that are `GraphFilter.Legal.YES`.

    - #### getVertexFilter

          public final Traversal.Admin<Vertex,Vertex> getVertexFilter()

      Get the vertex filter associated with this graph filter.
      Returns:
        the vertex filter or null if no vertex filter was provided.

    - #### getEdgeFilter

          public final Traversal.Admin<Vertex,Edge> getEdgeFilter()

      Get the edge filter associated with this graph filter.
      Returns:
        the edge filter or null if no edge filter was provided.

    - #### hasFilter

          public boolean hasFilter()

      Whether filters have been defined.
      Returns:
        true if either a vertex or edge filter has been provided.

    - #### hasEdgeFilter

          public boolean hasEdgeFilter()

      Whether an edge filter has been defined.
      Returns:
        true if an edge filter was provided.

    - #### hasVertexFilter

          public boolean hasVertexFilter()

      Whether a vertex filter has been defined.
      Returns:
        true if a vertex filter was provided.

    - #### getLegallyPositiveEdgeLabels

          public Set<String> getLegallyPositiveEdgeLabels(Direction direction)

      For a particular edge directionality, get all the `GraphFilter.Legal.YES` or `GraphFilter.Legal.MAYBE` edge labels. If the label set contains `null`, then all edge labels for that direction are positively legal.
      Parameters:
        `direction` - the direction to get the positively legal edge labels for.
      Returns:
        the set of positively legal edge labels for the direction.

    - #### checkEdgeLegality

          public GraphFilter.Legal checkEdgeLegality(Direction direction,
                                                     String label)

      Get the legality of a particular edge direction and label.
      Parameters:
        `direction` - the direction of the edge.
        `label` - the label of the edge.
      Returns:
        the `GraphFilter.Legal` of the arguments.

    - #### checkEdgeLegality

          public GraphFilter.Legal checkEdgeLegality(Direction direction)

      Get the legality of a particular edge direction.
      Parameters:
        `direction` - the direction of the edge.
      Returns:
        the `GraphFilter.Legal` of the edge direction.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(Object object)

      Overrides:
        `equals` in class `Object`

    - #### clone

          public GraphFilter clone()

      Overrides:
        `clone` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

Copyright © 2013–2018 Apache Software Foundation. All rights reserved.