#include #include #include #include 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; } }; }; struct RandomGraph:public ImportModule { RandomGraph(ClusterContext context):ImportModule(context) {} ~RandomGraph(){} bool import(const string &name) { timeb tmp; ftime(&tmp); srand(tmp.time); bool ok=true; int resMin = QInputDialog::getInteger( QString("Please enter the number of nodes of the graph "),QString("Number of nodes"), 0, 0, 1000000, 10, &ok ); if (!ok) return false; int resMax = QInputDialog::getInteger( QString("Please enter the number of edges"), QString("Number of edges"), 0 , 0, 1000000,10, &ok ); if (resMax>resMin*resMin) resMax=resMin*resMin; if (!ok) return false; int ite=resMax*resMin; int nbEdges=0; set myGraph; while (ite>0) { if (ite%resMin==1) if (!pluginProgress->progress(resMax*resMin-ite,resMax*resMin)) return false; edgeS tmp; tmp.source=rand()%resMin; tmp.target=rand()%resMin; if (myGraph.find(tmp)!=myGraph.end()) { myGraph.erase(tmp); nbEdges--; } else { if (nbEdges tmpVect(resMin); for (int i=0;iaddNode(); } set::iterator it; for (it=myGraph.begin();it!=myGraph.end();++it) { superGraph->addEdge(tmpVect[(*it).source],tmpVect[(*it).target]); } return true; } }; IMPORTPLUGIN(RandomGraph,"Random General Graph","Auber","16/06/2002","0","0","1")