Coverage details for edu.uci.ics.jung.graph.predicates.ReciprocatedDirectedEdgePredicate

LineHitsSource
1 /*
2  * Copyright (c) 2004, the JUNG Project and the Regents of the University of
3  * California All rights reserved.
4  *
5  * This software is open-source under the BSD license; see either "license.txt"
6  * or http://jung.sourceforge.net/license.txt for a description.
7  *
8  * Created on Jun 15, 2004
9  */
10 package edu.uci.ics.jung.graph.predicates;
11  
12 import java.util.Iterator;
13 import java.util.Set;
14  
15 import edu.uci.ics.jung.graph.ArchetypeEdge;
16 import edu.uci.ics.jung.graph.DirectedEdge;
17  
18 /**
19  * Returns <code>true</code> if and only if this edge is
20  * a <code>DirectedEdge</code> that has an antiparallel
21  * <code>DirectedEdge</code> in this graph. Two directed
22  * edges are antiparallel to one another if one edge's
23  * source is the other's destination, and vice versa.
24  *
25  * @author Joshua O'Madadhain
26  */
27 public class ReciprocatedDirectedEdgePredicate extends EdgePredicate
28 {
29     private static ReciprocatedDirectedEdgePredicate instance;
30     private static final String message = "ReciprocatedDirectedEdgePredicate";
31     
32     protected ReciprocatedDirectedEdgePredicate()
33     {
341        super();
351    }
36     
37     public static ReciprocatedDirectedEdgePredicate getInstance()
38     {
391        if (instance == null)
401            instance = new ReciprocatedDirectedEdgePredicate();
411        return instance;
42     }
43  
44     public String toString()
45     {
460        return message;
47     }
48  
49     /**
50      * @see edu.uci.ics.jung.graph.predicates.EdgePredicate#evaluateEdge(edu.uci.ics.jung.graph.ArchetypeEdge)
51      */
52     public boolean evaluateEdge(ArchetypeEdge e)
53     {
543        if (!(e instanceof DirectedEdge))
550            return false;
563        DirectedEdge de = (DirectedEdge)e;
57         
58         // get set of edges going the other direction...
593        Set edges = de.getDest().findEdgeSet(de.getSource());
603        for (Iterator iter = edges.iterator(); iter.hasNext(); )
61         {
62             // if any of these edges is directed, then the connection is
63             // reciprocated; return true
642            if (iter.next() instanceof DirectedEdge)
652                return true;
66         }
671        return false;
68     }
69  
70 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.