bcds.phison.clustering
Interface Clusterer<V,E>

All Superinterfaces:
WithEnvParams
All Known Implementing Classes:
Dummy, NoackLinLog, ZoneAsCluster

public interface Clusterer<V,E>
extends WithEnvParams

Defines methods that clustering algorithms must implement. Essentially, a clustering algorithm maps each node to a cluster id (a zero-based integer). The clustering is assumed to be based on an arbitrary numeric edge weight (for example, distance, volume of traffic).

Note, however, that only nodes are clustered; edges' membership to clusters is not taken into account by this interface.

The initialization of a Clusterer must be performed in the method setup(SimGraph, Map, Environ), and a default (nullary) construictor should be explicitly provided. This convention follows that of RoutingAlg. Please see that interface for further details.

Author:
Juan Segovia S.

Method Summary
 java.util.Map<V,java.lang.Integer> getNodeMapping()
          Returns a reference of the clustering map that was produced by run().
 java.util.Map<java.lang.Integer,java.util.List<V>> groupByClusterId()
          Returns a map that groups nodes by their cluster id.
 java.util.Map<V,java.lang.Integer> run()
          Executes the clustering algorithm and returns the node to cluster-id mapping.
 void setNodeMapping(java.util.Map<V,java.lang.Integer> m)
          Saves a reference to the map m as the node mapping.
 void setup(SimGraph<V,E> g, java.util.Map<E,? extends java.lang.Number> edge_cost, Environ env)
          Performs initialization of a new instance.
 
Methods inherited from interface bcds.phison.WithEnvParams
getEnviron, getEnvParams, getName
 

Method Detail

setup

void setup(SimGraph<V,E> g,
           java.util.Map<E,? extends java.lang.Number> edge_cost,
           Environ env)
Performs initialization of a new instance. See WithEnvParams.getEnvParams() for details about the expected format of the names in env.


run

java.util.Map<V,java.lang.Integer> run()
Executes the clustering algorithm and returns the node to cluster-id mapping. The first cluster id is 1.


getNodeMapping

java.util.Map<V,java.lang.Integer> getNodeMapping()
Returns a reference of the clustering map that was produced by run().


setNodeMapping

void setNodeMapping(java.util.Map<V,java.lang.Integer> m)
Saves a reference to the map m as the node mapping. Thus, overrides the result produced by run.


groupByClusterId

java.util.Map<java.lang.Integer,java.util.List<V>> groupByClusterId()
Returns a map that groups nodes by their cluster id. Schematically, the value returned is as follows:
   [0] -> (N3, N5, Nx, Ny)
   [1] -> (N0, Nw, ...)
   ...
 
The elements Nx, Ny, ..., Nz are sorted lexically in ascending order, using their "natural" ordering.