From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- .../adaptagrams/libcola/tests/small_graph.cpp | 111 +++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 src/3rdparty/adaptagrams/libcola/tests/small_graph.cpp (limited to 'src/3rdparty/adaptagrams/libcola/tests/small_graph.cpp') diff --git a/src/3rdparty/adaptagrams/libcola/tests/small_graph.cpp b/src/3rdparty/adaptagrams/libcola/tests/small_graph.cpp new file mode 100644 index 0000000..53103c9 --- /dev/null +++ b/src/3rdparty/adaptagrams/libcola/tests/small_graph.cpp @@ -0,0 +1,111 @@ +/* + * 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 + * +*/ + +// Loads a graph from a text file, generates constraints for each edge requiring them +// to point downwards, and proceeds to produce a layout using libcola. +// The input file format is 2 numeric node labels per line separated by a space, +// each pair representing a directed edge. Node labels are simply used as array +// offsets so they should start from 0. +// The graph should be connected. +// Default input file is the matrix market 1138_bus graph. +// Running times: +// no constraints - steepest descent solver: 149 seconds +// no constraints - conjugate gradient solver: 21.7 seconds +// dir-edge constraints - conj grad. solver: 155.69 seconds +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace cola; + +struct CheckProgress : TestConvergence { + CheckProgress(const double d,const unsigned i) : TestConvergence(d,i) {} + bool operator()(const double new_stress, valarray & X, valarray & Y) { + cout << "stress="< es; + CompoundConstraints cy; + //CompoundConstraints cx; + while(!getline(f,startlabel,' ').eof()) { + getline(f,endlabel); + unsigned start = atoi(startlabel.c_str()), + end = atoi(endlabel.c_str()); + es.push_back(make_pair(start,end)); + //cx.push_back( + //new SeparationConstraint(start,end,defaultEdgeLength/3)); + cy.push_back( + new SeparationConstraint(start,end,defaultEdgeLength/3)); + V=max(V,max(start,end)); + } + V++; + cout << "V="< rs; + //srand(time(nullptr)); + for(unsigned i=0;i