#include #include #include using namespace std; struct SmallWorldGraph:public ImportModule { SmallWorldGraph(ClusterContext context):ImportModule(context) {} ~SmallWorldGraph(){} bool import(const string &name) { timeb tmp; ftime(&tmp); srand(tmp.time); bool ok=true; int nbNodes = QInputDialog::getInteger( QString("Please enter the number of nodes"), QString("Number of nodes"), 0 , 0, 1000000,1, &ok ); if (!ok) return false; int maxDistance = QInputDialog::getInteger( QString("Please enter the maximum distance between two linked nodes"),QString("Maximaal distance"), 0, 0, 1000000, 1, &ok ); if (!ok) return false; if (!ok) return false; LayoutProxy *newLayout=getLocalProxy(superGraph,"viewLayout"); vector graph(nbNodes); for (int i=0; iaddNode(); newLayout->setNodeValue(graph[i],Coord(rand()%1024,rand()%1024,0)); } for (int i=0;igetNodeValue(graph[i]).dist(newLayout->getNodeValue(graph[j]))<(double)maxDistance) superGraph->addEdge(graph[i],graph[j]); } } return true; } }; IMPORTPLUGIN(SmallWorldGraph,"Small World Graph","Auber","25/06/2002","0","0","1")