| Line | Hits | Source |
|---|---|---|
| 1 | /* | |
| 2 | * Copyright (c) 2003, the JUNG Project and the Regents of the University | |
| 3 | * of California | |
| 4 | * All rights reserved. | |
| 5 | * | |
| 6 | * This software is open-source under the BSD license; see either | |
| 7 | * "license.txt" or | |
| 8 | * http://jung.sourceforge.net/license.txt for a description. | |
| 9 | */ | |
| 10 | /* | |
| 11 | * Created on May 9, 2004 | |
| 12 | */ | |
| 13 | package edu.uci.ics.jung.graph.predicates; | |
| 14 | ||
| 15 | import edu.uci.ics.jung.graph.*; | |
| 16 | import edu.uci.ics.jung.graph.ArchetypeEdge; | |
| 17 | import edu.uci.ics.jung.graph.DirectedEdge; | |
| 18 | import edu.uci.ics.jung.graph.Graph; | |
| 19 | import edu.uci.ics.jung.graph.impl.SparseTree; | |
| 20 | ||
| 21 | ||
| 22 | /** | |
| 23 | * @author danyelf | |
| 24 | */ | |
| 25 | 1 | public class TreePredicate extends EdgePredicate { |
| 26 | ||
| 27 | /** | |
| 28 | * Any edges added to this graph must go to a vertex where | |
| 29 | * | |
| 30 | * @see edu.uci.ics.jung.graph.predicates.EdgePredicate#evaluateEdge(edu.uci.ics.jung.graph.ArchetypeEdge) | |
| 31 | */ | |
| 32 | public boolean evaluateEdge(ArchetypeEdge e) { | |
| 33 | 5 | if (! Graph.DIRECTED_EDGE.evaluate(e) ) |
| 34 | 0 | return false; |
| 35 | 5 | DirectedEdge de = (DirectedEdge) e; |
| 36 | 5 | Vertex dest = de.getDest(); |
| 37 | 5 | if( dest.containsUserDatumKey(SparseTree.SPARSE_ROOT_KEY)) |
| 38 | 1 | return false; |
| 39 | 4 | if ( dest.inDegree () > 0) |
| 40 | 1 | return false; |
| 41 | ||
| 42 | 3 | Vertex src = de.getSource(); |
| 43 | 3 | if( !src.containsUserDatumKey(SparseTree.IN_TREE_KEY)) |
| 44 | 1 | return false; |
| 45 | 2 | return true; |
| 46 | } | |
| 47 | ||
| 48 | 1 | protected static TreePredicate instance = null; |
| 49 | ||
| 50 | /** | |
| 51 | * @return a <code>TreePredicate</code> instance | |
| 52 | */ | |
| 53 | public static TreePredicate getInstance() { | |
| 54 | 1 | if ( instance == null) |
| 55 | 1 | instance = new TreePredicate(); |
| 56 | 1 | return instance; |
| 57 | } | |
| 58 | ||
| 59 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |