Inkscape
Vector Graphics Editor
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages Concepts
page_bounds.cpp
Go to the documentation of this file.
1/*
2 * vim: ts=4 sw=4 et tw=0 wm=0
3 *
4 * libcola - A library providing force-directed network layout using the
5 * stress-majorization method subject to separation constraints.
6 *
7 * Copyright (C) 2006-2008 Monash University
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library in the file LICENSE; if not,
21 * write to the Free Software Foundation, Inc., 59 Temple Place,
22 * Suite 330, Boston, MA 02111-1307 USA
23 *
24*/
25
31#include<iostream>
32#include<vector>
33#include <cmath>
34#include <time.h>
35#include <valarray>
36
37#include "graphlayouttest.h"
38
39vector<Edge> random_graph(unsigned n) {
40 vector<Edge> edges;
41 for(unsigned i=1;i<n;i++) {
42 edges.push_back(make_pair(i-1,i));
43 }
44 for(unsigned i=0;i<n;i++) {
45 for(unsigned j=i+1;j<n;j++) {
46 double r=(double)rand()/(double)RAND_MAX;
47 if(r < 1./(double)n) {
48 edges.push_back(make_pair(i,j));
49 }
50 }
51 }
52
53 return edges;
54}
55int main() {
56 unsigned V=30;
57 CompoundConstraints ccs;
58 vector<Edge> es = random_graph(V);
59 double defaultEdgeLength=40;
61 new cola::PageBoundaryConstraints(0,200,0,200,100);
62
63 double w=2.0, h=2.0;
64 for(unsigned i=0;i<V;i++) {
65 pbc->addShape(i, w/2, h/2);
66 }
67 ccs.push_back(pbc);
68
69 cout << "V="<<V<<endl;
70 double width=1000;
71 double height=1000;
72 //srand(time(nullptr));
73 vector<pair<double,double> > startpos(V);
74 for(unsigned i=0;i<V;i++) {
75 double x=getRand(width), y=getRand(height);
76 startpos[i]=make_pair(x,y);
77 }
78
79 /*void run_test(
80 vector<pair<double,double> > const &startpos,
81 vector<Edge> const &es,
82 const double defaultEdgeLength,
83 CompoundConstraints &cx,
84 CompoundConstraints &cy,
85 const SolverType s,
86 const bool constrained,
87 const char *fname,
88 const char *testdesc) {
89 */
90
91/*
92 run_test(startpos,es,defaultEdgeLength,cx,cy,CG,false,"random","cg");
93 run_test(startpos,es,defaultEdgeLength,cx,cy,IP,false,"random", "ip");
94 run_test(startpos,es,defaultEdgeLength,cx,cy,UGP,false,"random", "ugp");
95 run_test(startpos,es,defaultEdgeLength,cx,cy,SGP,false,"random", "sgp");
96 run_test(startpos,es,defaultEdgeLength,cx,cy,IP,true,"random", "cip");
97 run_test(startpos,es,defaultEdgeLength,cx,cy,SGP,true,"random", "csgp");
98 */
99 run_test(startpos,es,defaultEdgeLength,ccs,UGP,true,"random", "cugp");
100 return 0;
101}
102// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4:textwidth=99 :
A page boundary contraint specifies constraints that attempt to keep the given nodes within a defined...
void addShape(unsigned index, double halfW, double halfH)
Mark a node as being contained within this page boundary.
const double w
Definition conic-4.cpp:19
double getRand(double range)
vector< Edge > es
void run_test(vector< pair< double, double > > const &startpos, vector< Edge > const &es, const double defaultEdgeLength, CompoundConstraints &ccs, const SolverType s, const bool constrained, const char *fname, const char *testdesc)
@ UGP
vector< Edge > random_graph(unsigned n)
int main()
Edges edges(Path const &p, Crossings const &cr, unsigned ix)
Definition sanitize.cpp:36
double height
double width