de.uni_leipzig.cvk.data.cluster
Class ClusterAlgorithm

java.lang.Object
  extended by de.uni_leipzig.cvk.data.cluster.ClusterAlgorithm
All Implemented Interfaces:
ClusterTableSettings
Direct Known Subclasses:
ClusterAlgorithmBorderFlow, ClusterAlgorithmKNN, ClusterAlgorithmMCL

public abstract class ClusterAlgorithm
extends java.lang.Object
implements ClusterTableSettings

Is an abstract base class for a concrete cluster algorithm implementation. A concrete algorithm just need to implement the clustering(String[], double, String, String, String, String) method. The four String parameters comes from the member String arrays config_A ,..., config_D and can be used for different configurations of an algorithm by overriding this members, e.g. use config_A = new String[]{"k","1",...,"100"} for parameter k of k-nearest neighbours algorithm. The first element in an array is a value for a JLabel which describes the configuration for the user. A user can choose the other elements of each array from a JComboBox in the application and this values will sent back to the clustering method as parameters so that they can be used for configurations.

The String filename member variable contains the path to a delimiter separated text file, separators are space, comma or tabulator. See getSeparator().

After a new algorithm has been implemented, it still needs to be added to the application. For this use the ClusterContext class with the ClusterContext.addAlgorithm(String, ClusterAlgorithm) method. For example, write in Main.clusterVisualizationKitDemo() method (which starts the application) the following:

Model model = new Model();
ClusterContext cc = model.getClusterContext();
cc.addAlgorithm("Foobar", new ClusterAlgorithmFoobar());

or modify the ClusterContext.ClusterContext() constructor to append the algorithm.

 

Field Summary
protected  java.lang.String[] config_A
          An array of default available settings, override this array for a concrete configuration.
protected  java.lang.String[] config_B
          An array of default available settings, override this array for a concrete configuration.
protected  java.lang.String[] config_C
          An array of default available settings, override this array for a concrete configuration.
protected  java.lang.String[] config_D
          An array of default available settings, override this array for a concrete configuration.
protected  java.lang.String filename
          path to file
 
Fields inherited from interface de.uni_leipzig.cvk.data.cluster.ClusterTableSettings
CLUSTER_COLUMN_ID, CLUSTER_COLUMN_ID_TYPE, CLUSTER_COLUMN_NAME, CLUSTER_COLUMN_NAME_TYPE, CLUSTER_COLUMN_SIZE, CLUSTER_COLUMN_SIZE_TYPE
 
Constructor Summary
ClusterAlgorithm()
           
 
Method Summary
 prefuse.data.Table cluster(java.lang.String[] seeds, double threshold, java.lang.String values_A, java.lang.String values_B, java.lang.String values_C, java.lang.String values_D)
          A template method to call the concrete clustering method.
protected abstract  prefuse.data.Table clustering(java.lang.String[] seeds, double threshold, java.lang.String values_A, java.lang.String values_B, java.lang.String values_C, java.lang.String values_D)
          An abstract method for a concrete clustering algorithm implementation or adaption.
 java.lang.String[] getA()
          gets available configuration
 java.lang.String[] getB()
          gets available configuration
 java.lang.String[] getC()
          gets available configuration
 java.lang.String[] getD()
          gets available configuration
 java.lang.String getSeparator()
          gets the separator of filename depends on the file extension
protected  prefuse.data.Table getTable()
          gets a valid Table, that means with a column of ClusterTableSettings.CLUSTER_COLUMN_NAME and a type of ClusterTableSettings.CLUSTER_COLUMN_NAME_TYPE for the cluster data
 void setFilename(java.lang.String name)
          sets filename, the path to file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

config_A

protected java.lang.String[] config_A
An array of default available settings, override this array for a concrete configuration. The first element in config_A is a value of a JLabel instance shown in the application. All other elements in config_A are values which are given back to clustering(String[], double, String, String, String, String).


config_B

protected java.lang.String[] config_B
An array of default available settings, override this array for a concrete configuration. The first element in config_B is a value of a JLabel instance shown in the application. All other elements in config_B are values which are given back to clustering(String[], double, String, String, String, String).


config_C

protected java.lang.String[] config_C
An array of default available settings, override this array for a concrete configuration. The first element in config_C is a value of a JLabel instance shown in the application. All other elements in config_C are values which are given back to clustering(String[], double, String, String, String, String).


config_D

protected java.lang.String[] config_D
An array of default available settings, override this array for a concrete configuration. The first element in config_D is a value of a JLabel instance shown in the application. All other elements in config_D are values which are given back to clustering(String[], double, String, String, String, String).


filename

protected java.lang.String filename
path to file

Constructor Detail

ClusterAlgorithm

public ClusterAlgorithm()
Method Detail

cluster

public final prefuse.data.Table cluster(java.lang.String[] seeds,
                                        double threshold,
                                        java.lang.String values_A,
                                        java.lang.String values_B,
                                        java.lang.String values_C,
                                        java.lang.String values_D)
A template method to call the concrete clustering method. Checks the cluster table format for validity. (ClusterTableSettings.CLUSTER_COLUMN_NAME and ClusterTableSettings.CLUSTER_COLUMN_NAME_TYPE) Sorts clusterTable parameter with the column ClusterTableSettings.CLUSTER_COLUMN_SIZE.

Parameters:
seeds - all selected seeds
threshold - threshold is between 0 and 1 or -1 for all nodes
values_A - value of config_A array
values_B - value of config_B array
values_C - value of config_C array
values_D - value of config_D array
Returns:
table with one or more columns, null if wrong cluster table format

clustering

protected abstract prefuse.data.Table clustering(java.lang.String[] seeds,
                                                 double threshold,
                                                 java.lang.String values_A,
                                                 java.lang.String values_B,
                                                 java.lang.String values_C,
                                                 java.lang.String values_D)
An abstract method for a concrete clustering algorithm implementation or adaption. The clustering method gets the cluster back in a table with a column name of ClusterTableSettings.CLUSTER_COLUMN_NAME and with a column type of ClusterTableSettings.CLUSTER_COLUMN_NAME_TYPE. The column ClusterTableSettings.CLUSTER_COLUMN_SIZE is reserved for a inner sort operation, you don't have to use it, but you can use this column to add the size of a cluster with type of ClusterTableSettings.CLUSTER_COLUMN_SIZE_TYPE, but be sure that every row is set with a value. This size defines the order of printing the clusters, the highest value of size for a cluster will print first.

Parameters:
seeds - selected nodes that will be used as seeds
threshold - threshold is between 0 and 1 or -1 for all nodes
values_A - value of config_A array
values_B - value of config_B array
values_C - value of config_C array
values_D - value of config_D array
Returns:
table with one or more columns

getA

public java.lang.String[] getA()
gets available configuration


getB

public java.lang.String[] getB()
gets available configuration


getC

public java.lang.String[] getC()
gets available configuration


getD

public java.lang.String[] getD()
gets available configuration


getSeparator

public java.lang.String getSeparator()
gets the separator of filename depends on the file extension

Returns:
"," if file extension is *.csv
" " if file extension is *.ssv
"\t" if file extension is *.tab or *.txt

getTable

protected prefuse.data.Table getTable()
gets a valid Table, that means with a column of ClusterTableSettings.CLUSTER_COLUMN_NAME and a type of ClusterTableSettings.CLUSTER_COLUMN_NAME_TYPE for the cluster data


setFilename

public void setFilename(java.lang.String name)
sets filename, the path to file