cola.cpp revision aaacc83e3fab3c943e5d3b59646109b6b92c08dd
#include "cola.h"
#include "conjugate_gradient.h"
#include "straightener.h"
#include "shortest_paths.h"
namespace cola {
/**
* Find the euclidean distance between a pair of dummy variables
*/
inline double dummy_var_euclidean_dist(GradientProjection* gpx, GradientProjection* gpy, unsigned i) {
}
double* eweights,
double idealLength,
: constrainedLayout(false),
tol(0.0001),
X(new double[n]),
Y(new double[n]),
{
double** D=new double*[n];
for(unsigned i=0;i<n;i++) {
D[i]=new double[n];
}
// 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;
}
delete [] D[i];
}
delete [] D;
}
void
::setupDummyVars() {
double* coords[2]={X,Y};
for(unsigned k=0;k<2;k++) {
gp[k]->clearDummyVars();
if(clusters) {
}
}
}
}
for(unsigned k=0;k<2;k++) {
if(n_d > 0) {
for(unsigned i=0; i<n_d; i++) {
}
}
}
}
{
double b[n];
fill(b,b+n,0);
}
{
/* compute the vector b */
/* multiply on-the-fly with distance-based laplacian */
for (unsigned i = 0; i < n; i++) {
degree = 0;
if(i<lapSize) {
for (unsigned j = 0; j < lapSize; j++) {
if (j == i) continue;
dist_ij = euclidean_distance(i, j);
/* calculate L_ij := w_{ij}*d_{ij}/dist_{ij} */
}
}
}
}
if(constrainedLayout) {
} else {
}
}
inline double ConstrainedMajorizationLayout
::compute_stress(double **Dij) {
for (unsigned i = 1; i < lapSize; i++) {
for (unsigned j = 0; j < i; j++) {
d = Dij[i][j];
diff = d - euclidean_distance(i,j);
}
}
}
}
return sum;
}
/*
void ConstrainedMajorizationLayout
::addLinearConstraints(LinearConstraints* linearConstraints) {
n=lapSize+linearConstraints->size();
Q=new double*[n];
X=new double[n];
Y=new double[n];
for(unsigned i = 0; i<n; i++) {
X[i]=rs[i]->getCentreX();
Y[i]=rs[i]->getCentreY();
Q[i]=new double[n];
for(unsigned j=0; j<n; j++) {
if(i<lapSize&&j<lapSize) {
Q[i][j]=lap2[i][j];
} else {
Q[i][j]=0;
}
}
}
for(LinearConstraints::iterator i=linearConstraints->begin();
i!= linearConstraints->end();i++) {
LinearConstraint* c=*i;
Q[c->u][c->u]+=c->w*c->duu;
Q[c->u][c->v]+=c->w*c->duv;
Q[c->u][c->b]+=c->w*c->dub;
Q[c->v][c->u]+=c->w*c->duv;
Q[c->v][c->v]+=c->w*c->dvv;
Q[c->v][c->b]+=c->w*c->dvb;
Q[c->b][c->b]+=c->w*c->dbb;
Q[c->b][c->u]+=c->w*c->dub;
Q[c->b][c->v]+=c->w*c->dvb;
}
}
*/
bool ConstrainedMajorizationLayout::run() {
/*
for(unsigned i=0;i<n;i++) {
for(unsigned j=0;j<n;j++) {
cout << lap2[i][j] << " ";
}
cout << endl;
}
*/
do {
/* Axis-by-axis optimization: */
if(straightenEdges) {
} else {
}
return true;
}
static bool straightenToProjection=true;
for (unsigned i=0;i<lapSize;i++) {
}
Q=new double*[n];
delete [] X;
delete [] Y;
X=new double[n];
Y=new double[n];
for(unsigned i = 0; i<n; i++) {
X[i]=snodes[i]->x;
Y[i]=snodes[i]->y;
Q[i]=new double[n];
for(unsigned j=0; j<n; j++) {
Q[i][j]=lap2[i][j];
} else {
Q[i][j]=0;
}
}
}
// take u and v as the ends of the line
//unsigned u=path[0];
//unsigned v=path[path.size()-1];
double total_length=0;
total_length+=euclidean_distance(u,v);
}
// find new u and v for each line segment
unsigned u=path[j-1];
unsigned b=path[j];
unsigned v=path[j+1];
double weight=-0.01;
}
}
//cout << "Generated "<<linearConstraints.size()<< " linear constraints"<<endl;
fill(b,b+n,0);
i!= linearConstraints.end();i++) {
LinearConstraint* c=*i;
if(straightenToProjection) {
Q[c->u][c->u]+=c->w*c->duu;
Q[c->u][c->v]+=c->w*c->duv;
Q[c->u][c->b]+=c->w*c->dub;
Q[c->v][c->u]+=c->w*c->duv;
Q[c->v][c->v]+=c->w*c->dvv;
Q[c->v][c->b]+=c->w*c->dvb;
Q[c->b][c->b]+=c->w*c->dbb;
Q[c->b][c->u]+=c->w*c->dub;
Q[c->b][c->v]+=c->w*c->dvb;
} else {
Q[c->u][c->u]-=wub;
Q[c->u][c->b]+=wub;
Q[c->v][c->v]-=wbv;
Q[c->v][c->b]+=wbv;
Q[c->b][c->u]+=wub;
Q[c->b][c->v]+=wbv;
}
}
constrainedLayout = true;
sedges[i]->createRouteFromPath(X,Y);
}
delete cs[i];
}
for(unsigned i=0;i<linearConstraints.size();i++) {
delete linearConstraints[i];
}
delete snodes[i];
}
for(unsigned i = 0; i<n; i++) {
delete [] Q[i];
}
delete [] Q;
}
bool avoidOverlaps,
constrainedLayout = true;
this->avoidOverlaps = avoidOverlaps;
if(cs) {
}
gpX=new GradientProjection(
gpY=new GradientProjection(
this->straightenEdges = straightenEdges;
}
} // namespace cola
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4