Changeset 2407

Show
Ignore:
Timestamp:
08/15/08 15:53:14 (3 months ago)
Author:
mwlinnem
Message:

Made it more intuitive to extract the bottom X nodes instead of the top.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plugins/preprocessing/edu.iu.nwb.preprocessing.extractnodesandedges/OSGI-INF/metatype/METADATA.XML

    r2369 r2407  
    44                 description="Extract the top N nodes from a graph, based on a given attribute "> 
    55                <AD name="Extract N top nodes" id="numTopNodes" type="Integer" description="Extracts this many of the top nodes from the graph" default="1"/> 
    6                 <AD name="Descending?" id="ascendingOrDescending" type="Boolean" description="Extract from the bottom up or from the top down?" default="true"/> 
     6                <AD name="Extract bottom nodes instead?" id="fromBottomInstead" type="Boolean" description="Extract the bottom nodes instead of the top" default="false"/> 
    77                <AD name="Numeric Attribute" id="numericAttribute" type="String" description="The attribute which the nodes will be sorted by" default=""/> 
    88        </OCD> 
     
    2323                 description="Extract the top N edges from a graph, based on a given attribute "> 
    2424                <AD name="Extract N top edges" id="numTopEdges" type="Integer" description="Extracts this many of the top edges from the graph" default="1"/> 
    25                 <AD name="Descending?" id="ascendingOrDescending" type="Boolean" description="Extract from the bottom up or from the top down?" default="true"/> 
     25                <AD name="Extract bottom edges instead?" id="fromBottomInstead" type="Boolean" description="Extract the bottom edges instead of the top" default="false"/> 
    2626                <AD name="Numeric Attribute" id="numericAttribute" type="String" description="The attribute which the edges will be sorted by" default=""/> 
    2727        </OCD> 
  • trunk/plugins/preprocessing/edu.iu.nwb.preprocessing.extractnodesandedges/src/edu/iu/nwb/preprocessing/extractnodesandedges/extractedges/top/ExtractTopEdgesAlgorithm.java

    r2162 r2407  
    1717import edu.uci.ics.jung.utils.GraphUtils; 
    1818 
    19 public class ExtractTopEdgesAlgorithm implements Algorithm { 
    20          
    21         private static final boolean ASCENDING = true; 
    22         private static final boolean DESCENDING = false; 
    23          
     19public class ExtractTopEdgesAlgorithm implements Algorithm {     
    2420    Data[] data; 
    2521    Dictionary parameters; 
    2622    CIShellContext context; 
    2723    private int numTopEdges; 
    28     private boolean ascendingOrDescending
     24    private boolean fromBottomInstead
    2925    private String numericAttribute; 
    3026     
     
    4440         
    4541        this.numTopEdges = ((Integer) parameters.get("numTopEdges")).intValue(); 
    46         this.ascendingOrDescending = ((Boolean) parameters.get("ascendingOrDescending")).booleanValue(); 
     42        this.fromBottomInstead = ((Boolean) parameters.get("fromBottomInstead")).booleanValue(); 
    4743        this.numericAttribute = (String) parameters.get("numericAttribute"); 
    4844    } 
     
    6864        Set edgesToRemove = new HashSet(); 
    6965        //if we want to keep the top X... 
    70         if (ascendingOrDescending == ASCENDING) { 
     66        if (! fromBottomInstead) { 
    7167                //delete from the bottom up, until we have X left 
    7268                while (edgesByRank.size() > numTopEdges) { 
     
    7672                } 
    7773        } //else if want to keep the bottom X... 
    78         else { 
     74        else {//bottomInstead == FROM_BOTTOM 
    7975                //skip the first X from the bottom up 
    8076                for (int ii = 0; ii < numTopEdges && (!edgesByRank.isEmpty()); ii++) { 
     
    9591    private Data[] formatAsData(Graph extractedGraph) { 
    9692        StringBuilder label = new StringBuilder(); 
    97         if (this.ascendingOrDescending) { 
     93        if (this.fromBottomInstead) { 
     94                label.append("bottom "); 
     95        } else { 
    9896                label.append("top "); 
    99         } else { 
    100                 label.append("bottom "); 
    10197        } 
    10298        label.append("" + this.numTopEdges); 
  • trunk/plugins/preprocessing/edu.iu.nwb.preprocessing.extractnodesandedges/src/edu/iu/nwb/preprocessing/extractnodesandedges/extractnodes/top/ExtractTopNodesAlgorithm.java

    r2162 r2407  
    1818 
    1919public class ExtractTopNodesAlgorithm implements Algorithm { 
    20         private static final boolean ASCENDING = true; 
    21         private static final boolean DESCENDING = false; 
    2220         
    2321    Data[] data; 
     
    2523    CIShellContext context; 
    2624    private int numTopNodes; 
    27     private boolean ascendingOrDescending
     25    private boolean fromBottomInstead
    2826    private String numericAttribute; 
    2927     
     
    4341         
    4442        this.numTopNodes = ((Integer) parameters.get("numTopNodes")).intValue(); 
    45         this.ascendingOrDescending = ((Boolean) parameters.get("ascendingOrDescending")).booleanValue(); 
     43        this.fromBottomInstead = ((Boolean) parameters.get("fromBottomInstead")).booleanValue(); 
    4644        this.numericAttribute = (String) parameters.get("numericAttribute"); 
    4745    } 
     
    6765        Set nodesToRemove = new HashSet(); 
    6866        //if we want to keep the top X... 
    69         if (ascendingOrDescending == ASCENDING) { 
     67        if (fromBottomInstead != true) { 
    7068                //delete from the bottom up, until we have X left 
    7169                while (nodesByRank.size() > numTopNodes) { 
     
    9492    private Data[] formatAsData(Graph extractedGraph) { 
    9593        StringBuilder label = new StringBuilder(); 
    96         if (this.ascendingOrDescending) { 
     94        if (this.fromBottomInstead) { 
     95                label.append("bottom "); 
     96        } else { 
    9797                label.append("top "); 
    98         } else { 
    99                 label.append("bottom "); 
    10098        } 
    10199        label.append("" + this.numTopNodes);