/* * 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 * */ #include #include #include //#define TEST_AGAINST_BOOST #ifdef TEST_AGAINST_BOOST #include #include #include #include #include using namespace boost; #endif // TEST_AGAINST_BOOST #include #include #include #include using namespace std; // creates a (not necessarily connected random graph) with n nodes. vector random_graph(unsigned n) { vector edges; for(unsigned i=0;i > > Graph; Graph g; #endif unsigned V = 100; vector es = random_graph(V); unsigned E=es.size(); cout << " Test graph |V|="< weights(E); for(unsigned i=0;i(rand())/static_cast(RAND_MAX))*10); #ifdef TEST_AGAINST_BOOST add_edge(es[i].first,es[i].second,weights[i],g); #endif } #ifdef TEST_AGAINST_BOOST vector < double >d(V, (numeric_limits < double >::max)()); typedef vector weight_vec; vector D(V,weight_vec(V)); cout<<"Running boost::johnson_all_pairs_shortest_paths..."< "; for (unsigned int j = 0; j < V; ++j) { if(dump) cout << setw(5) << D1[i][j]; assert(D1[i][j]==D2[i][j]); #ifdef TEST_AGAINST_BOOST assert(D[i][j]==D2[i][j]); #endif } if(dump) cout << endl; } #ifdef TEST_AGAINST_BOOST if(dump) { ofstream fout("figs/johnson-eg.dot"); fout << "graph A {\n" << "node[shape=\"circle\"]\n"; graph_traits < Graph >::edge_iterator ei, ei_end; for (tie(ei, ei_end) = edges(g); ei != ei_end; ++ei) fout << source(*ei, g) << " -- " << target(*ei, g) << "[label=" << get(edge_weight, g)[*ei] << "]\n"; fout << "}\n"; } #endif return 0; }