/* * 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