summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fb5bcb2)
raw | patch | inline | side by side (parent: fb5bcb2)
author | tgdwyer <tgdwyer@users.sourceforge.net> | |
Mon, 17 Jul 2006 06:03:13 +0000 (06:03 +0000) | ||
committer | tgdwyer <tgdwyer@users.sourceforge.net> | |
Mon, 17 Jul 2006 06:03:13 +0000 (06:03 +0000) |
src/libcola/cola.cpp | patch | blob | history | |
src/libcola/cola.h | patch | blob | history | |
src/libvpsc/solve_VPSC.cpp | patch | blob | history |
diff --git a/src/libcola/cola.cpp b/src/libcola/cola.cpp
index 3499d729a6110db3b2bd8851d43d9b5348416262..74cab50daca440f4225bfcc311443bff56c2d4fb 100644 (file)
--- a/src/libcola/cola.cpp
+++ b/src/libcola/cola.cpp
#include "cola.h"
#include "conjugate_gradient.h"
#include "straightener.h"
+#include "shortest_paths.h"
namespace cola {
dy = gpy->dummy_vars[i]->place_r - gpy->dummy_vars[i]->place_l;
return sqrt(dx*dx + dy*dy);
}
+ConstrainedMajorizationLayout
+::ConstrainedMajorizationLayout(
+ vector<Rectangle*>& rs,
+ vector<Edge>& es,
+ double* eweights,
+ double idealLength,
+ TestConvergence& done)
+ : constrainedLayout(false),
+ n(rs.size()),
+ lapSize(n), lap2(new double*[lapSize]),
+ Q(lap2), Dij(new double*[lapSize]),
+ tol(0.0001),
+ done(done),
+ X(new double[n]),
+ Y(new double[n]),
+ clusters(NULL),
+ linearConstraints(NULL),
+ gpX(NULL),
+ gpY(NULL),
+ straightenEdges(NULL)
+{
+ assert(rs.size()==n);
+ boundingBoxes = new Rectangle*[rs.size()];
+ copy(rs.begin(),rs.end(),boundingBoxes);
+
+ done.reset();
+
+ double** D=new double*[n];
+ for(unsigned i=0;i<n;i++) {
+ D[i]=new double[n];
+ }
+ shortest_paths::johnsons(n,D,es,eweights);
+ edge_length = idealLength;
+ // Lij_{i!=j}=1/(Dij^2)
+ //
+ for(unsigned i = 0; i<n; i++) {
+ X[i]=rs[i]->getCentreX();
+ Y[i]=rs[i]->getCentreY();
+ double degree = 0;
+ lap2[i]=new double[n];
+ Dij[i]=new double[n];
+ for(unsigned j=0;j<n;j++) {
+ double w = edge_length * D[i][j];
+ Dij[i][j]=w;
+ if(i==j) continue;
+ degree+=lap2[i][j]=w>1e-30?1.f/(w*w):0;
+ }
+ lap2[i][i]=-degree;
+ delete [] D[i];
+ }
+ delete [] D;
+}
void
ConstrainedMajorizationLayout
diff --git a/src/libcola/cola.h b/src/libcola/cola.h
index c3cdb03c00f7e59478095260e16f2657e058ad0d..b56d2327e1f94613873cc8ff5450712c7821cbbf 100644 (file)
--- a/src/libcola/cola.h
+++ b/src/libcola/cola.h
#include <cmath>
#include <iostream>
#include <cassert>
-#include "shortest_paths.h"
#include "gradient_projection.h"
-#include <libvpsc/generate-constraints.h>
#include "straightener.h"
typedef vector<unsigned> Cluster;
typedef vector<Cluster*> Clusters;
-
-using vpsc::Rectangle;
+namespace vpsc { class Rectangle; }
namespace cola {
+ using vpsc::Rectangle;
typedef pair<unsigned, unsigned> Edge;
// a graph component with a list of node_ids giving indices for some larger list of nodes
vector<Edge>& es,
double* eweights,
double idealLength,
- TestConvergence& done=defaultTest)
- : constrainedLayout(false),
- n(rs.size()),
- lapSize(n), lap2(new double*[lapSize]),
- Q(lap2), Dij(new double*[lapSize]),
- tol(0.0001),
- done(done),
- X(new double[n]),
- Y(new double[n]),
- clusters(NULL),
- linearConstraints(NULL),
- gpX(NULL),
- gpY(NULL),
- straightenEdges(NULL)
- {
- assert(rs.size()==n);
- boundingBoxes = new Rectangle*[rs.size()];
- copy(rs.begin(),rs.end(),boundingBoxes);
-
- done.reset();
-
- double** D=new double*[n];
- for(unsigned i=0;i<n;i++) {
- D[i]=new double[n];
- }
- shortest_paths::johnsons(n,D,es,eweights);
- edge_length = idealLength;
- // Lij_{i!=j}=1/(Dij^2)
- //
- for(unsigned i = 0; i<n; i++) {
- X[i]=rs[i]->getCentreX();
- Y[i]=rs[i]->getCentreY();
- double degree = 0;
- lap2[i]=new double[n];
- Dij[i]=new double[n];
- for(unsigned j=0;j<n;j++) {
- double w = edge_length * D[i][j];
- Dij[i][j]=w;
- if(i==j) continue;
- degree+=lap2[i][j]=w>1e-30?1.f/(w*w):0;
- }
- lap2[i][i]=-degree;
- delete [] D[i];
- }
- delete [] D;
- }
+ TestConvergence& done=defaultTest);
void moveBoundingBoxes() {
for(unsigned i=0;i<lapSize;i++) {
index ff0ff96bf373afb016d4dd4f7e232ba0184fcf12..ec2c48d46a45bfcb566b60c5e91caab370227cf1 100644 (file)
// Solve shouldn't loop indefinately
// ... but just to make sure we limit the number of iterations
unsigned maxtries=100;
- while(!solved&&maxtries>=0) {
+ while(!solved&&maxtries>0) {
solved=true;
maxtries--;
for(set<Block*>::const_iterator i=bs->begin();i!=bs->end();++i) {