| 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 | package edu.uci.ics.jung.graph.filters.impl; | |
| 11 | ||
| 12 | import edu.uci.ics.jung.graph.Vertex; | |
| 13 | import edu.uci.ics.jung.graph.filters.Filter; | |
| 14 | import edu.uci.ics.jung.graph.filters.GeneralVertexAcceptFilter; | |
| 15 | ||
| 16 | /** | |
| 17 | * Accepts only nodes that have at least one edge--that is, nodes that | |
| 18 | * are connected to one other node. This removes isolates, usually in order | |
| 19 | * to clean up visualizations. This is NOT an EfficientFilter. | |
| 20 | * <p>Because there | |
| 21 | * are no settable parameters, this is set as a factory method--to | |
| 22 | * get a <tt>DropSoloNodesFilter<tt>, just invoke | |
| 23 | * <pre> | |
| 24 | * Filter f = DropSoloNodesFilter.getInstance(); | |
| 25 | * </pre> | |
| 26 | * @author danyelf | |
| 27 | */ | |
| 28 | public class DropSoloNodesFilter extends GeneralVertexAcceptFilter { | |
| 29 | ||
| 30 | public boolean acceptVertex(Vertex vert) { | |
| 31 | 27 | boolean b = (vert.getIncidentEdges().size() > 0); |
| 32 | // if (vert.getIncidentEdges().size() == 1) { | |
| 33 | // if (vert.getNeighbors().contains( vert )) { | |
| 34 | // System.out.println("loop!"); | |
| 35 | // } | |
| 36 | // } | |
| 37 | // if ( !b ) { | |
| 38 | // System.out.println( "Drop " + vert.toString() ); | |
| 39 | // } | |
| 40 | 27 | return b; |
| 41 | } | |
| 42 | ||
| 43 | public String getName() { | |
| 44 | 3 | return "DropSoloNodes"; |
| 45 | } | |
| 46 | ||
| 47 | ||
| 48 | 1 | static DropSoloNodesFilter dsn = null; |
| 49 | ||
| 50 | public static Filter getInstance() { | |
| 51 | 4 | if ( dsn == null ) |
| 52 | 1 | dsn = new DropSoloNodesFilter(); |
| 53 | 4 | return dsn; |
| 54 | } | |
| 55 | ||
| 56 | 1 | protected DropSoloNodesFilter() { |
| 57 | 1 | } |
| 58 | ||
| 59 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |