at.tuwien.ifs.somtoolbox.visualization
Class NeighbourhoodGraph

java.lang.Object
  extended by at.tuwien.ifs.somtoolbox.visualization.AbstractBackgroundImageVisualizer
      extended by at.tuwien.ifs.somtoolbox.visualization.NeighbourhoodGraph
All Implemented Interfaces:
BackgroundImageVisualizer, Comparable<BackgroundImageVisualizer>

public class NeighbourhoodGraph
extends AbstractBackgroundImageVisualizer

This visualisation provides two visualization plugin-ins for neighbourhood graphs. The first one uses knn-based distances, the second one radius-based distances.
Described in:
Georg Poelzlbauer, Andreas Rauber, and Michael Dittenbach. Advanced visualization techniques for self-organizing maps with graph-based methods. In Jun Wang, Xiaofeng Liao, Zhang Yi, editors, Proceedings of the Second International Symposium on Neural Networks (ISNN'05), pages 75-80, Chongqing, China, May 30 - June 1 2005. Springer-Verlag.

Version:
$Id: NeighbourhoodGraph.java 3883 2010-11-02 17:13:23Z frank $
Author:
Stefan Ruemmele, Christian Kapeller, Frank Pourvoyeur, Rudolf Mayer

Nested Class Summary
private  class NeighbourhoodGraph.NeighbourhoodControlPanel
          The control panel for the two plug-ins, containing a JSpinner.
 
Nested classes/interfaces inherited from class at.tuwien.ifs.somtoolbox.visualization.AbstractBackgroundImageVisualizer
AbstractBackgroundImageVisualizer.ContourInterpolationMode, AbstractBackgroundImageVisualizer.ContourMode, AbstractBackgroundImageVisualizer.VisualizationControlPanel
 
Field Summary
private  int currentVisualization
           
private  InputVectorDistanceMatrix distanceMatrix
           
private  InputData inputData
           
private  int k
          number of neighbours for knn-based distances
private  ArrayList<UnitPair>[] knnLinesCache
          caches the results of knn-based connections
private static int MAX_K
           
private static double MAX_RADIUS
           
private  DistanceMetric metric
           
private static int MIN_K
           
private static double MIN_RADIUS
           
private  NeighbourhoodGraph.NeighbourhoodControlPanel neighbourhoodPanel
          control panel for this plug-in
(package private)  int numVectors
           
private  double radius
          radius for radius-based distances
private  Hashtable<Double,ArrayList<UnitPair>> radiusLinesCache
          caches the results of radius-based connections
 
Fields inherited from class at.tuwien.ifs.somtoolbox.visualization.AbstractBackgroundImageVisualizer
cache, CACHE_KEY_SECTION_SEPARATOR, CACHE_KEY_SEPARATOR, contourInterpolationMode, contourMode, controlPanel, currentZDimSlice, inputObjects, interpolate, log, map, MAX_CACHE_SIZE_MB, neededInputObjects, NUM_VISUALIZATIONS, numberOfContours, opacity, preferredScaleFactor, VISUALIZATION_DESCRIPTIONS, VISUALIZATION_NAMES, VISUALIZATION_SHORT_NAMES, visualizationUpdateListener, zSize
 
Fields inherited from interface at.tuwien.ifs.somtoolbox.visualization.BackgroundImageVisualizer
DEFAULT_BACKGROUND_VISUALIZATION_SCALE
 
Constructor Summary
NeighbourhoodGraph()
          Constructor.
 
Method Summary
private  ArrayList<UnitPair> createKNNBased(GrowingSOM gsom, int width, int height)
          Returns a list of unit-pairs, for which at least one of the two units is one of the k-nearest neighbours of the other one.
private  ArrayList<UnitPair> createRadiusBased(GrowingSOM gsom, int width, int height)
          Returns a list of unit-pairs, for which the distance of at least one of them to the other one is smaller than the fixed radius.
 BufferedImage createVisualization(int index, GrowingSOM gsom, int width, int height)
          Creates a visualisation image.
protected  String getCacheKey(GrowingSOM gsom, int index, int width, int height)
          The key of a cache is created as follows: VisualisationShortName + Hashcode of the SOM + Width + Height + Opacity.
Sub-classes might add more information to the cache, if needed.
 HashMap<String,BufferedImage> getVisualizationFlavours_K(int index, GrowingSOM gsom, int width, int height)
           
 HashMap<String,BufferedImage> getVisualizationFlavours_R(int index, GrowingSOM gsom, int width, int height)
           
 HashMap<String,BufferedImage> getVisualizationFlavours(int index, GrowingSOM gsom, int width, int height)
          Default implementation which returns a map of size 1 with the standard, unparameterised visualisation of the given variant.
 HashMap<String,BufferedImage> getVisualizationFlavours(int index, GrowingSOM gsom, int width, int height, int maxFlavours)
          Default implementation equal to AbstractBackgroundImageVisualizer.getVisualizationFlavours(int, GrowingSOM, int, int).
 HashMap<String,BufferedImage> getVisualizationFlavours(int index, GrowingSOM gsom, int width, int height, Map<String,String> flavourParameters)
          Default implementation equal to AbstractBackgroundImageVisualizer.getVisualizationFlavours(int, GrowingSOM, int, int).
 String[] needsAdditionalFiles()
          Checks whether this visualisation still needs some input files to generate an image.
 
Methods inherited from class at.tuwien.ifs.somtoolbox.visualization.AbstractBackgroundImageVisualizer
appendToCacheKey, buildCacheKey, checkNeededObjectsAvailable, checkVariantIndex, clearVisualisationCache, compareTo, createVisualization, drawBackground, getControlPanel, getHTMLVisualisationControl, getNumberOfVisualizations, getPreferredScaleFactor, getVariantException, getVisualization, getVisualizationDescription, getVisualizationDescriptions, getVisualizationName, getVisualizationNames, getVisualizationShortName, getVisualizationShortNames, invalidateCache, logImageCache, setInputObjects, setMap, setSOMData, setVisualizationUpdateListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIN_K

private static final int MIN_K
See Also:
Constant Field Values

MAX_K

private static final int MAX_K
See Also:
Constant Field Values

MIN_RADIUS

private static final double MIN_RADIUS
See Also:
Constant Field Values

MAX_RADIUS

private static final double MAX_RADIUS
See Also:
Constant Field Values

k

private int k
number of neighbours for knn-based distances


radius

private double radius
radius for radius-based distances


neighbourhoodPanel

private NeighbourhoodGraph.NeighbourhoodControlPanel neighbourhoodPanel
control panel for this plug-in


currentVisualization

private int currentVisualization

inputData

private InputData inputData

distanceMatrix

private InputVectorDistanceMatrix distanceMatrix

metric

private DistanceMetric metric

knnLinesCache

private ArrayList<UnitPair>[] knnLinesCache
caches the results of knn-based connections


radiusLinesCache

private Hashtable<Double,ArrayList<UnitPair>> radiusLinesCache
caches the results of radius-based connections


numVectors

int numVectors
Constructor Detail

NeighbourhoodGraph

public NeighbourhoodGraph()
Constructor.

Method Detail

createVisualization

public BufferedImage createVisualization(int index,
                                         GrowingSOM gsom,
                                         int width,
                                         int height)
                                  throws SOMToolboxException
Description copied from class: AbstractBackgroundImageVisualizer
Creates a visualisation image. Subclasses must implement this method.

Specified by:
createVisualization in class AbstractBackgroundImageVisualizer
Parameters:
index - the index of the variant to use
gsom - the GrowingSOM to take build the visualisation for
width - the desired width of the image, in pixels
height - the desired height of the image, in pixels.
Returns:
an image for this visualisation.
Throws:
SOMToolboxException

createKNNBased

private ArrayList<UnitPair> createKNNBased(GrowingSOM gsom,
                                           int width,
                                           int height)
                                    throws SOMToolboxException
Returns a list of unit-pairs, for which at least one of the two units is one of the k-nearest neighbours of the other one.

Throws:
SOMToolboxException

createRadiusBased

private ArrayList<UnitPair> createRadiusBased(GrowingSOM gsom,
                                              int width,
                                              int height)
                                       throws SOMToolboxException
Returns a list of unit-pairs, for which the distance of at least one of them to the other one is smaller than the fixed radius.

Throws:
SOMToolboxException

getCacheKey

protected String getCacheKey(GrowingSOM gsom,
                             int index,
                             int width,
                             int height)
Description copied from class: AbstractBackgroundImageVisualizer
The key of a cache is created as follows: VisualisationShortName + Hashcode of the SOM + Width + Height + Opacity.
Sub-classes might add more information to the cache, if needed.

Overrides:
getCacheKey in class AbstractBackgroundImageVisualizer

getVisualizationFlavours_K

public HashMap<String,BufferedImage> getVisualizationFlavours_K(int index,
                                                                GrowingSOM gsom,
                                                                int width,
                                                                int height)
                                                         throws SOMToolboxException
Throws:
SOMToolboxException

getVisualizationFlavours_R

public HashMap<String,BufferedImage> getVisualizationFlavours_R(int index,
                                                                GrowingSOM gsom,
                                                                int width,
                                                                int height)
                                                         throws SOMToolboxException
Throws:
SOMToolboxException

getVisualizationFlavours

public HashMap<String,BufferedImage> getVisualizationFlavours(int index,
                                                              GrowingSOM gsom,
                                                              int width,
                                                              int height)
                                                       throws SOMToolboxException
Description copied from class: AbstractBackgroundImageVisualizer
Default implementation which returns a map of size 1 with the standard, unparameterised visualisation of the given variant. Subclasses that want to return more flavours should override this method.

Specified by:
getVisualizationFlavours in interface BackgroundImageVisualizer
Overrides:
getVisualizationFlavours in class AbstractBackgroundImageVisualizer
Throws:
SOMToolboxException

getVisualizationFlavours

public HashMap<String,BufferedImage> getVisualizationFlavours(int index,
                                                              GrowingSOM gsom,
                                                              int width,
                                                              int height,
                                                              int maxFlavours)
                                                       throws SOMToolboxException
Description copied from class: AbstractBackgroundImageVisualizer
Default implementation equal to AbstractBackgroundImageVisualizer.getVisualizationFlavours(int, GrowingSOM, int, int).

Specified by:
getVisualizationFlavours in interface BackgroundImageVisualizer
Overrides:
getVisualizationFlavours in class AbstractBackgroundImageVisualizer
Throws:
SOMToolboxException

getVisualizationFlavours

public HashMap<String,BufferedImage> getVisualizationFlavours(int index,
                                                              GrowingSOM gsom,
                                                              int width,
                                                              int height,
                                                              Map<String,String> flavourParameters)
                                                       throws SOMToolboxException
Description copied from class: AbstractBackgroundImageVisualizer
Default implementation equal to AbstractBackgroundImageVisualizer.getVisualizationFlavours(int, GrowingSOM, int, int).

Specified by:
getVisualizationFlavours in interface BackgroundImageVisualizer
Overrides:
getVisualizationFlavours in class AbstractBackgroundImageVisualizer
Throws:
SOMToolboxException

needsAdditionalFiles

public String[] needsAdditionalFiles()
Description copied from interface: BackgroundImageVisualizer
Checks whether this visualisation still needs some input files to generate an image.

Specified by:
needsAdditionalFiles in interface BackgroundImageVisualizer
Overrides:
needsAdditionalFiles in class AbstractBackgroundImageVisualizer
Returns:
an array containing the names of the input objects needed