Writing a graph class
Here is my constructor and I wanted to ask, would this be equivalent to the overall look of web graph? I'm just making a 2D array where (I think) all the indecies are vertices, one vertex joining 2 or more other vertext(indecies). Am I correct?
Graph:: Graph (int numVertices) {
th开发者_JS百科is -> numVertices = numVertices;
//memory alocated for elements of rows.
adjMatrix = new double*[numVertices];
//memory allocated for elements of each column
for(int i =0; i < numVertices; i++)
adjMatrix[i] = new double[numVertices];
for(int i =0; i < numVertices; i++)
for (int j=0; j< numVertices; j++)
adjMatrix[i][j] = INFINITY;
}
精彩评论