#include #include #include #include #include #include #include #include #include #include "QuotientClustering.h" CLUSTERINGPLUGIN(QuotientClustering,"QuotientClustering","David Auber","13/06/2001","Alpha","0","1"); using namespace std; struct edgeS { unsigned source,target; }; namespace std { template <> struct less { bool operator()(const edgeS &c,const edgeS &d) const { if (c.sourced.source) return false; if (c.targetd.target) return false; return false; } }; }; //================================================================================ QuotientClustering::QuotientClustering(ClusterContext context):Clustering(context) {} //================================================================================ QuotientClustering::~QuotientClustering(){} namespace STL_EXT_NS { template <> struct hash { size_t operator()(const double s) const { return (size_t)s; } }; }; //=============================================================================== bool QuotientClustering::run() { SuperGraph *quotientGraph=TlpTools::newSubGraph(superGraph->getClusterTree()->getRootSubGraph()->getAssociatedSuperGraph()); SubGraph *quotientSubGraph=quotientGraph->getSubGraph(); MetaGraphProxy *meta=getProxy(quotientGraph,"viewMetaGraph"); //parcourir tous les sous graphe du graphe courant. //et construit les metanoeud dans le quotient graphe. SubGraph *graph= superGraph->getSubGraph(); map mapping; std::list *subgraphs=graph->getSubGraphChildren(); for (std::list::iterator it=subgraphs->begin();it!=subgraphs->end();++it) { if ((*it)!=quotientSubGraph) { node n=quotientGraph->addNode(); meta->setNodeValue(n,(*it)->getAssociatedSuperGraph()); mapping[(*it)]=n; } } set myQuotientGraph; Iterator*itE=superGraph->getEdges(); for (;itE->hasNext();) { edge ite=itE->next(); node source=superGraph->source(ite); node target=superGraph->target(ite); list clusterSource; list clusterTarget; clusterSource.clear(); clusterTarget.clear(); for (std::list::iterator it=subgraphs->begin();it!=subgraphs->end();++it) { if (*it!=quotientSubGraph) { SuperGraph *tmp=(*it)->getAssociatedSuperGraph(); if (tmp->isElement(source)) clusterSource.push_back(*it); if (tmp->isElement(target)) clusterTarget.push_back(*it); } } for (std::list::iterator it1=clusterSource.begin();it1!=clusterSource.end();++it1) for (std::list::iterator it2=clusterTarget.begin();it2!=clusterTarget.end();++it2) { // cerr << "." ; edgeS tmp; tmp.source=mapping[*it1].id; tmp.target=mapping[*it2].id; // pair< node , node > tmpPair(,mapping[*it2]); if ( ((*it1)!=(*it2)) && (myQuotientGraph.find(tmp)==myQuotientGraph.end()) ) { // cerr<< "addedge" << endl; myQuotientGraph.insert(tmp); quotientGraph->addEdge(mapping[*it1],mapping[*it2]); } } }delete itE; if (dataSet!=0) { // cerr << "Quotient set data set" << endl; dataSet->set("quotientGraph",quotientGraph); } return true; } //================================================================================ bool QuotientClustering::check(string &erreurMsg) { erreurMsg=""; return true; } //================================================================================ void QuotientClustering::reset(){} //================================================================================