Line | Hits | Source |
---|---|---|
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 | { | |
34 | 1 | super(); |
35 | 1 | } |
36 | ||
37 | public static ReciprocatedDirectedEdgePredicate getInstance() | |
38 | { | |
39 | 1 | if (instance == null) |
40 | 1 | instance = new ReciprocatedDirectedEdgePredicate(); |
41 | 1 | return instance; |
42 | } | |
43 | ||
44 | public String toString() | |
45 | { | |
46 | 0 | 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 | { | |
54 | 3 | if (!(e instanceof DirectedEdge)) |
55 | 0 | return false; |
56 | 3 | DirectedEdge de = (DirectedEdge)e; |
57 | ||
58 | // get set of edges going the other direction... | |
59 | 3 | Set edges = de.getDest().findEdgeSet(de.getSource()); |
60 | 3 | for (Iterator iter = edges.iterator(); iter.hasNext(); ) |
61 | { | |
62 | // if any of these edges is directed, then the connection is | |
63 | // reciprocated; return true | |
64 | 2 | if (iter.next() instanceof DirectedEdge) |
65 | 2 | return true; |
66 | } | |
67 | 1 | return false; |
68 | } | |
69 | ||
70 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |