#include #include #include #include #include #include #include "EqualValueClustering.h" CLUSTERINGPLUGIN(EqualValueClustering,"Equal Value","David Auber","13/06/2001","Alpha","0","1"); using namespace std; //================================================================================ EqualValueClustering::EqualValueClustering(ClusterContext context):Clustering(context) {} //================================================================================ EqualValueClustering::~EqualValueClustering() {} namespace STL_EXT_NS { template <> struct hash { size_t operator()(const double s) const { return (size_t)s; } }; }; //=============================================================================== bool EqualValueClustering::run() { string tmp1,tmp2; PropertyProxyContainer *ppC=superGraph->getPropertyProxyContainer(); MetricProxy *metric=getProxy(superGraph,"viewMetric"); STL_EXT_NS::hash_map partitions; int curPart=0; Iterator *itN=superGraph->getNodes(); for (;itN->hasNext();) { node itn=itN->next(); double tmp=metric->getNodeValue(itn); if (partitions.find(tmp)==partitions.end()) { partitions[tmp]=curPart; curPart++; } } delete itN; SelectionProxy *selection =getLocalProxy(superGraph,"tmp select"); selection->setAllNodeValue(false); selection->setAllEdgeValue(false); map newClusters; char str[100]; for (int i=0;iaddView(str,selection)->getAssociatedSuperGraph(); } itN=superGraph->getNodes(); for (;itN->hasNext();) { node itn=itN->next(); double tmp=metric->getNodeValue(itn); newClusters[partitions[tmp]]->addNode(itn); }delete itN; Iterator *itE=superGraph->getEdges(); for(;itE->hasNext();) { edge ite=itE->next(); double tmp; if ((tmp=metric->getNodeValue(superGraph->source(ite)))==metric->getNodeValue(superGraph->target(ite))) { newClusters[partitions[tmp]]->addEdge(ite); } }delete itE; ppC->delLocalProxy("tmp select"); return true; } //================================================================================ bool EqualValueClustering::check(string &erreurMsg) { erreurMsg=""; return true; } //================================================================================ void EqualValueClustering::reset() { } //================================================================================