All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.uci.ics.jung.algorithms.util.SelfLoopEdgePredicate Maven / Gradle / Ivy

There is a newer version: 2.1.1
Show newest version
package edu.uci.ics.jung.algorithms.util;

import com.google.common.base.Predicate;

import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.graph.util.Context;
import edu.uci.ics.jung.graph.util.Pair;

/**
 * A Predicate that returns true if the input edge's 
 * endpoints in the input graph are identical.  (Thus, an edge which connects
 * its sole incident vertex to itself).
 *
 * @param  the vertex type
 * @param  the edge type
 */
public class SelfLoopEdgePredicate implements Predicate,E>> {

    public boolean apply(Context,E> context) {
        Pair endpoints = context.graph.getEndpoints(context.element);
        return endpoints.getFirst().equals(endpoints.getSecond());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy