From ab5f8ff5869021958f4ae8b838c3d707a2e85eaa Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sun, 29 Apr 2018 16:25:32 +0200 Subject: Put adaptagrams into its own folder --- src/libcola/tests/scale_free.cpp | 135 --------------------------------------- 1 file changed, 135 deletions(-) delete mode 100644 src/libcola/tests/scale_free.cpp (limited to 'src/libcola/tests/scale_free.cpp') diff --git a/src/libcola/tests/scale_free.cpp b/src/libcola/tests/scale_free.cpp deleted file mode 100644 index d9c2934e7..000000000 --- a/src/libcola/tests/scale_free.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * vim: ts=4 sw=4 et tw=0 wm=0 - * - * libcola - A library providing force-directed network layout using the - * stress-majorization method subject to separation constraints. - * - * Copyright (C) 2006-2008 Monash University - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library in the file LICENSE; if not, - * write to the Free Software Foundation, Inc., 59 Temple Place, - * Suite 330, Boston, MA 02111-1307 USA - * -*/ - -// generates a random graph with a power-law distribution of node degrees -// the algorithm is pretty much the Barabasi-Albert model but with an extra step -// so that I can guarantee the number of nodes in the graph. -// We begin with an initial chain of m nodes. -// Then, we add new nodes, connecting them to existing nodes v with probability -// degree(v)/(sum all degrees) -// We perform an extra step, looking for disconnected nodes, connecting them -// to other nodes again with probability dependent on degree -#include -#include -#include -#include -#include - -#include "graphlayouttest.h" - -void scale_free(const unsigned n = 50) { - const unsigned m = 3; // begin with a chain of m nodes - const double g=0.08; // edge density, every time we add a node we add 1+g*rand(0-1) edges - // connecting them to existing nodes with probability based on degree - unsigned d[n]; - double defaultEdgeLength=100; - vector es; - CompoundConstraints cx,cy; - for(unsigned i=0;ig) { - es.push_back(make_pair(j,i)); - d[j]++;d[i]++; - sumdegree+=2; - } - } - } - for(unsigned i=0;imaxP) { - maxP=r*p; - end=j; - } - } - if(end>i) { - es.push_back(make_pair(i,end)); - } else { - es.push_back(make_pair(end,i)); - } - d[end]++;d[i]++; - sumdegree+=2; - } - } - valarray eweights(es.size()); - sort(d,d+n); - unsigned degree=0,ctr=0; - printf("degree distribution:\n"); - for(unsigned i=0;i