This file contains the code for the Spectral Graph Embedding Method via Sampled Spectral Distance Embedding (SSDE). Given a graph this program returns the embedding of the nodes into Cartesian space where the Euclidean distances between nodes approximates the path distance in the original graph.
Eli Bocek-Rivele, Ali Civril, and Jonathan Purnell.
SSDE.h | This file contains the code for the Spectral Graph Embedding Method via Sampled Spectral Distance Embedding (SSDE). |
Enumerations | |
Type of Sampling nodes | |
Node | This class holds the information for a node in the graph. |
Node Name File | |
Graph File | |
Coordinates File | |
Functions | |
Node | Default constructor (puts space for 5 neighbors) |
Node | Constructor that allocates memory for info on node’s neighbors. |
insert | Adds neighbor and edge weight. |
resize | Allocates more memory for neighbor info. |
dotProduct | Calculate dot product of two vectors. |
mag | Calculate magnitude of vector. |
normalize | Normalizes vector in-place |
multCons | Returns vector resulting from multiplying input vector by input constant. |
minusSSDE | Returns the difference between two vectors. |
multGamma | Returns vector who’s elements average to zero. |
makeOrtho | Makes first input vector orthogonal to second input vector. |
multL | Multiplies C*INV*R |
multGammaLGamma | Simplifies the sequence of multiplying input vector by Gamma, by L and then by Gamma again. |
readNodes | Loads the list of nodes names. |
readFile | Loads the graph data. |
writeFile | Writes the coordinates of the embedded nodes. |
BFS | Breadth First Search. |
allBFS | Based on sampling method, samples nodes from the graph and determines the distances from the sampled nodes to all other nodes in the graph. |
randomSampleCR | Samples nodes from the graph randomly. |
house | Returns the householder vector and the associated beta, given the size and the vector x. |
bidiagonalize | Bidiagonalizes a given matrix A by overwriting it, also returns Ue and Ve which are the elements in the expression Ue^T*A*Ve = B (A is overwritten as B) A is supposed to be an m*n matrix where m >= n, Ub is m*m, Vb is n*n |
givens | computes cos(theta) c and sin(theta) c given a and b. |
SVDstep | Applies Givens rotations to the matrix on B bounded by upper and lower indices (call this Bbar). |
sample | Calculates all the necessary matrices involved in sampling (also performs the SVD algorithm). |
powerIteration | Performs power iterations to find the largest eigenvectors of our distance matrix. |
normalizeCoords | Normalizes the coordinates of the embedded graph. |
writeGraph | Function for finding the Strongly Connected Components in the graph. |
Tarjan | Function to perform the Tarjan algorithm. |
Functions | |
Node | Default constructor (puts space for 5 neighbors) |
Node | Constructor that allocates memory for info on node’s neighbors. |
insert | Adds neighbor and edge weight. |
resize | Allocates more memory for neighbor info. |
dotProduct | Calculate dot product of two vectors. |
mag | Calculate magnitude of vector. |
normalize | Normalizes vector in-place |
multCons | Returns vector resulting from multiplying input vector by input constant. |
minusSSDE | Returns the difference between two vectors. |
multGamma | Returns vector who’s elements average to zero. |
makeOrtho | Makes first input vector orthogonal to second input vector. |
multL | Multiplies C*INV*R |
multGammaLGamma | Simplifies the sequence of multiplying input vector by Gamma, by L and then by Gamma again. |
readNodes | Loads the list of nodes names. |
readFile | Loads the graph data. |
writeFile | Writes the coordinates of the embedded nodes. |
BFS | Breadth First Search. |
allBFS | Based on sampling method, samples nodes from the graph and determines the distances from the sampled nodes to all other nodes in the graph. |
randomSampleCR | Samples nodes from the graph randomly. |
house | Returns the householder vector and the associated beta, given the size and the vector x. |
bidiagonalize | Bidiagonalizes a given matrix A by overwriting it, also returns Ue and Ve which are the elements in the expression Ue^T*A*Ve = B (A is overwritten as B) A is supposed to be an m*n matrix where m >= n, Ub is m*m, Vb is n*n |
givens | computes cos(theta) c and sin(theta) c given a and b. |
SVDstep | Applies Givens rotations to the matrix on B bounded by upper and lower indices (call this Bbar). |
sample | Calculates all the necessary matrices involved in sampling (also performs the SVD algorithm). |
powerIteration | Performs power iterations to find the largest eigenvectors of our distance matrix. |
normalizeCoords | Normalizes the coordinates of the embedded graph. |
writeGraph | Function for finding the Strongly Connected Components in the graph. |
Tarjan | Function to perform the Tarjan algorithm. |
void readNodes( char * fileName )
Loads the list of nodes names. The format of this file is outlined in Node Name File. A hash table is create so that the node names can be translated to their index in nodes[] in constant time.
void readFile( char * fileName )
Loads the graph data. Format of this file follows Graph File.
void writeFile( char * fileName )
Writes the coordinates of the embedded nodes. Format of the file follows Coordinates File.
void bidiagonalize( double ** A, double ** Ub, double ** Vb, int m, int n )
Bidiagonalizes a given matrix A by overwriting it, also returns Ue and Ve which are the elements in the expression Ue^T*A*Ve = B (A is overwritten as B) A is supposed to be an m*n matrix where m >= n, Ub is m*m, Vb is n*n
void SVDstep( double ** B, double ** Ue, double ** Ve, int lower, int upper )
Applies Givens rotations to the matrix on B bounded by upper and lower indices (call this Bbar). Overwrites Bbar with Ue^T*B*Ve, also calculates Ue and Ve in this formula Ue and Ve are treated as a whole (not only the parts remaining between upper and lower indices) They are first initialized to I, and accumulated accordingly.
Default constructor (puts space for 5 neighbors)
Node( string name )
Adds neighbor and edge weight.
void insert( int neighbor, double dist )
Allocates more memory for neighbor info.
void resize( int newSize )
Loads the list of nodes names.
void readNodes( char * fileName )
Loads the graph data.
void readFile( char * fileName )
Writes the coordinates of the embedded nodes.
void writeFile( char * fileName )
Based on sampling method, samples nodes from the graph and determines the distances from the sampled nodes to all other nodes in the graph.
void allBFS( int samplingMethod )
Returns the householder vector and the associated beta, given the size and the vector x.
void house( double * v, double * x, int size, double * beta )
Bidiagonalizes a given matrix A by overwriting it, also returns Ue and Ve which are the elements in the expression Ue^T*A*Ve = B (A is overwritten as B) A is supposed to be an m*n matrix where m >= n, Ub is m*m, Vb is n*n
void bidiagonalize( double ** A, double ** Ub, double ** Vb, int m, int n )
computes cos(theta) c and sin(theta) c given a and b.
void givens( double a, double b, double * c, double * s )
Applies Givens rotations to the matrix on B bounded by upper and lower indices (call this Bbar).
void SVDstep( double ** B, double ** Ue, double ** Ve, int lower, int upper )
Calculates all the necessary matrices involved in sampling (also performs the SVD algorithm).
void sample()
Performs power iterations to find the largest eigenvectors of our distance matrix.
void powerIteration()
Normalizes the coordinates of the embedded graph.
void normalizeCoords()
Function for finding the Strongly Connected Components in the graph.
void writeGraph( std:: deque<int> & S )
Function to perform the Tarjan algorithm.
void Tarjan( int v, int & index, std:: deque<int> & S, ofstream & scc_file )