开发者

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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜