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 PredicateUtils

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

public class PredicateUtils
extends Object

Convenience methods for handling Predicates in JUNG (as constraints, as subset specifications, and in general). Not a replacement for the Jakarta Commons-Collections `PredicateUtils` class.

Author:
  Joshua O'Madadhain

Constructor Summary
`PredicateUtils()`

Method Summary
`static boolean` | `addEdgeSubset(ArchetypeGraph g, Predicate p)` Creates an edge subset for `g` based on `p`, which will be maintained by the `g`'s `SubsetManager`.
`static boolean` | `addVertexSubset(ArchetypeGraph g, Predicate p)` Creates a vertex subset for `g` based on `p`, which will be maintained by the `g`'s `SubsetManager`.
`static boolean` | `enforcesDirected(Graph g)` Returns `true` if `g` is constrained to only accept directed edges, and false otherwise.
`static boolean` | `enforcesEdgeConstraint(ArchetypeGraph g, Predicate p)` Returns `true` if `p` is an edge constraint of `g`, and `false` otherwise.
`static boolean` | `enforcesNotParallel(Graph g)` Returns `true` if `g` is constrained to reject parallel edges.
`static boolean` | `enforcesUndirected(Graph g)` Returns `true` if `g` is constrained to only accept undirected edges.
`static boolean` | `enforcesVertexConstraint(ArchetypeGraph g, Predicate p)` Returns `true` if `p` is an edge constraint of `g`, and `false` otherwise.
`static Map` | `evaluateNestedPredicates(Predicate p, Object o)` Returns a `Map` of each constituent predicate of `p` (if any) to the result of evaluating this predicate on `o`.
`static Set` | `getEdges(ArchetypeGraph g, Predicate p)` Returns a `Set` consisting of all edges `e` in graph `g` that satisfy predicate `p`, that is, those for which `p.evaluate(e)` returns true.
`static Collection` | `getSatisfyingElements(Collection c, Predicate p)`
`static Set` | `getVertices(ArchetypeGraph g, Predicate p)` Returns a `Set` consisting of all vertices `v` in graph `g` that satisfy predicate `p`, that is, those for which `p.evaluate(v)` returns true.
`static void` | `removeEdgeSubset(ArchetypeGraph g, Predicate p)` Removes the edge subset based on `p` from `g`'s `SubsetManager`.
`static void` | `removeVertexSubset(ArchetypeGraph g, Predicate p)` Removes the vertex subset based on `p` from `g`'s `SubsetManager`.
`static boolean` | `satisfiesEdgeConstraint(ArchetypeGraph g, Predicate p)` Returns `true` if each edge in `g` satisfies `p`, and false otherwise.
`static boolean` | `satisfiesPredicate(Collection c, Predicate p)` Returns `true` if all elements of `c` satisfy `p`.
`static boolean` | `satisfiesVertexConstraint(ArchetypeGraph g, Predicate p)` Returns `true` if each vertex in `g` satisfies `p`, and false otherwise.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PredicateUtils

    public PredicateUtils()

Method Detail

### getVertices

    public static Set getVertices(ArchetypeGraph g,
                                  Predicate p)

  Returns a `Set` consisting of all vertices `v` in graph `g` that satisfy predicate `p`, that is, those for which `p.evaluate(v)` returns true.

  If `g` has a `SubsetManager` that defines a cached subset based on `p`, that subset is returned.

### getEdges

    public static Set getEdges(ArchetypeGraph g,
                               Predicate p)

  Returns a `Set` consisting of all edges `e` in graph `g` that satisfy predicate `p`, that is, those for which `p.evaluate(e)` returns true.

### addVertexSubset

    public static boolean addVertexSubset(ArchetypeGraph g,
                                          Predicate p)

  Creates a vertex subset for `g` based on `p`, which will be maintained by the `g`'s `SubsetManager`.

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

### addEdgeSubset

    public static boolean addEdgeSubset(ArchetypeGraph g,
                                        Predicate p)

  Creates an edge subset for `g` based on `p`, which will be maintained by the `g`'s `SubsetManager`.

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

### removeVertexSubset

    public static void removeVertexSubset(ArchetypeGraph g,
                                          Predicate p)

  Removes the vertex subset based on `p` from `g`'s `SubsetManager`.

  Parameters:
    `p` - the predicate defining the subset

### removeEdgeSubset

    public static void removeEdgeSubset(ArchetypeGraph g,
                                        Predicate p)

  Removes the edge subset based on `p` from `g`'s `SubsetManager`.

  Parameters:
    `p` - the predicate defining the subset

### enforcesEdgeConstraint

    public static boolean enforcesEdgeConstraint(ArchetypeGraph g,
                                                 Predicate p)

  Returns `true` if `p` is an edge constraint of `g`, and `false` otherwise.

### satisfiesEdgeConstraint

    public static boolean satisfiesEdgeConstraint(ArchetypeGraph g,
                                                  Predicate p)

  Returns `true` if each edge in `g` satisfies `p`, and false otherwise. (Note: this may be true even if `p` is not a constraint of `g`.)

### enforcesVertexConstraint

    public static boolean enforcesVertexConstraint(ArchetypeGraph g,
                                                   Predicate p)

  Returns `true` if `p` is an edge constraint of `g`, and `false` otherwise.

### satisfiesVertexConstraint

    public static boolean satisfiesVertexConstraint(ArchetypeGraph g,
                                                    Predicate p)

  Returns `true` if each vertex in `g` satisfies `p`, and false otherwise. (Note: this may be true even if `p` is not a constraint of `g`.)

### satisfiesPredicate

    public static boolean satisfiesPredicate(Collection c,
                                             Predicate p)

  Returns `true` if all elements of `c` satisfy `p`.

### getSatisfyingElements

    public static Collection getSatisfyingElements(Collection c,
                                                   Predicate p)

### enforcesDirected

    public static boolean enforcesDirected(Graph g)

  Returns `true` if `g` is constrained to only accept directed edges, and false otherwise.

### enforcesUndirected

    public static boolean enforcesUndirected(Graph g)

  Returns `true` if `g` is constrained to only accept undirected edges.

### enforcesNotParallel

    public static boolean enforcesNotParallel(Graph g)

  Returns `true` if `g` is constrained to reject parallel edges.

  See Also:
    `ParallelEdgePredicate`

### evaluateNestedPredicates

    public static Map evaluateNestedPredicates(Predicate p,
                                               Object o)

  Returns a `Map` of each constituent predicate of `p` (if any) to the result of evaluating this predicate on `o`. If `p` is a `PredicateDecorator`, i.e., a predicate that operates on other `Predicate`s, the output will consist of the results of evaluting the constituents of `p` on `o`; otherwise, the output will be the result of evaluating `p` itself on `o`.

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