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 Apr 23, 2003 | |
12 | */ | |
13 | package edu.uci.ics.jung.graph.filters.impl; | |
14 | ||
15 | import edu.uci.ics.jung.graph.Edge; | |
16 | import edu.uci.ics.jung.graph.decorators.EdgeWeightLabeller; | |
17 | import edu.uci.ics.jung.graph.filters.EfficientFilter; | |
18 | import edu.uci.ics.jung.graph.filters.GeneralEdgeAcceptFilter; | |
19 | import edu.uci.ics.jung.graph.filters.LevelFilter; | |
20 | ||
21 | /** | |
22 | * This simple filter accepts Edges if their EdgeWeightLabeller turns out | |
23 | * to be greater than the input value. | |
24 | * @author danyelf | |
25 | */ | |
26 | public class WeightedEdgeGraphFilter | |
27 | extends GeneralEdgeAcceptFilter | |
28 | implements LevelFilter, EfficientFilter { | |
29 | ||
30 | 30 | public WeightedEdgeGraphFilter(int threshold, EdgeWeightLabeller el) { |
31 | 30 | setValue(threshold); |
32 | 30 | this.labels = el; |
33 | 30 | } |
34 | ||
35 | /** (non-Javadoc) | |
36 | * @see edu.uci.ics.jung.graph.filters.Filter#getName() | |
37 | */ | |
38 | public String getName() { | |
39 | 46 | return "WeightedGraph(" + threshold + ")"; |
40 | } | |
41 | ||
42 | private int threshold; | |
43 | private EdgeWeightLabeller labels; | |
44 | ||
45 | public void setValue(int threshold) { | |
46 | 69 | this.threshold = threshold; |
47 | 69 | } |
48 | ||
49 | public int getValue() { | |
50 | 10 | return threshold; |
51 | } | |
52 | ||
53 | public boolean acceptEdge(Edge e) { | |
54 | // Edge edge = GraphUtils.getCorrespondingEdge( labels.getGraph(), e ); | |
55 | 368 | Edge edge = (Edge)e.getEqualEdge(labels.getGraph()); |
56 | 368 | int val = labels.getWeight( edge ); |
57 | // ((Integer) e.getUserDatum(WEIGHT_KEY)).intValue(); | |
58 | 368 | if (val < threshold) { |
59 | // System.out.println("Rejected something!"); | |
60 | } | |
61 | 368 | return (val >= threshold); |
62 | } | |
63 | ||
64 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |