/************************************************ Functions for computing the high-dimensional embedding and the PCA projection. ************************************************/ #include #include #include #include "EmbedderDefs.h" #include "EmbedderDijkstra.h" #include "EmbedderBfs.h" #include "EmbedderParameters.h" //#define WEIGHTED_GRAPH typedef DistType * dist_ptr; typedef double * double_ptr; unsigned int high_dim_time, center_time, pca_matrix_time, power_iteration_time, projection_time; void embed_graph(vtx_data * graph, int n, int dim, DistType ** (&coords)) { high_dim_time = clock(); int i,j; if (coords!=NULL) { delete [] coords[0]; delete [] coords; } DistType * storage = new DistType[n*dim]; coords = new dist_ptr[dim]; // this matrix stores the distance between each node and each "pivot" for (i=0; imax_dist) { node=i; max_dist=dist[i]; } } // select other dim-1 nodes as pivots for (i=1; imax_dist) { node=j; max_dist=dist[j]; } } } delete [] dist; high_dim_time=clock()-high_dim_time; } // Make each axis centered around 0 void center_coordinate(DistType ** coords, int n, int dim) { center_time=clock(); int i,j; double sum,avg; for (i=0; i