'Graph Implementation with Adjacency Matrix and Strings

I'm trying to change my graph from accepting an integers as Vertices to strings. The folllowing is my Graph and Edge structures:

typedef struct GraphRep {
    int **edges;    // adjacency matrix storing positive weights
                    // 0 if nodes not adjacent
    int nV;         // #vertices
    int nE;         // #edges
} GraphRep;

typedef struct GraphRep *Graph;

typedef char *Vertex;

typedef struct Edge {
    Vertex v;
    Vertex w;
    int weight;
} Edge;

The following functions were written previously now having problems because I no longer can do indexing...

// check if vertex is valid in a graph
int validV(Graph g, Vertex v) {
    return (g != NULL && v >= 0 && v < g->nV);
}


void insertEdge(Graph g, Edge e) {
    assert(g != NULL && validV(g,e.v) && validV(g,e.w));

    if (g->edges[e.v][e.w] == 0) {   // edge e not in graph
        g->edges[e.v][e.w] = e.weight;
        g->nE++;
    }
}

I'm really stuck and not sure where to go from here. Could you please suggest what should I do to make it work? Also it would be appreciated if you can point me to an example of Graph implementation with vertices are strings.

Thank you very much!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source