1 package edu.uci.ics.jung.algorithms.util;
3 import org.apache.commons.collections15.Predicate;
5 import edu.uci.ics.jung.graph.Graph;
6 import edu.uci.ics.jung.graph.util.Context;
7 import edu.uci.ics.jung.graph.util.Pair;
10 * A <code>Predicate</code> that returns <code>true</code> if the input edge's
11 * endpoints in the input graph are identical. (Thus, an edge which connects
12 * its sole incident vertex to itself).
17 public class SelfLoopEdgePredicate<V,E> implements Predicate<Context<Graph<V,E>,E>> {
19 public boolean evaluate(Context<Graph<V,E>,E> context) {
20 Pair<V> endpoints = context.graph.getEndpoints(context.element);
21 return endpoints.getFirst().equals(endpoints.getSecond());