Graph/C/Prim.c
void prim(Graph* G, int index) {
    int min;
    Edge* edge = initEdge(G, index);
    for (int i = 0; i < G -> vexNum - 1; i++) {
        min = getMinEdge(edge, G);
        printf("v%c --> v%c, weight = %d\n", edge[min].vex, G -> vexs[min], edge[min].weight);
        edge[min].weight = 0;
        for (int j = 0; j < G -> vexNum; j++) {
            if (G -> arcs[min][j] < edge[j].weight) {
                edge[j].weight = G -> arcs[min][j];
                edge[j].vex = G -> vexs[min];
            }
        }
    }
}
/**
 * prim
 * @param G the pointer of graph
 * @param index the index of you visited
 */
prim
@param G the pointer of graph
@param index the index of you visited
prim @param G the pointer of graph @param index the index of you visited
void prim(Graph* G, int index) {
    int min;
    Edge* edge = initEdge(G, index);
    for (int i = 0; i < G -> vexNum - 1; i++) {
        min = getMinEdge(edge, G);
        printf("v%c --> v%c, weight = %d\n", edge[min].vex, G -> vexs[min], edge[min].weight);
        edge[min].weight = 0;
        for (int j = 0; j < G -> vexNum; j++) {
            if (G -> arcs[min][j] < edge[j].weight) {
                edge[j].weight = G -> arcs[min][j];
                edge[j].vex = G -> vexs[min];
            }
        }
    }
}
void prim ( Graph * G , int index ) { int min ; Edge * edge = initEdge ( G , index ) ; for ( int i = 0 ; i < G -> vexNum - 1 ; i ++ ) { min = getMinEdge ( edge , G ) ; printf ( " \n " , edge [ min ] . vex , G -> vexs [ min ] , edge [ min ] . weight ) ; edge [ min ] . weight = 0 ; for ( int j = 0 ; j < G -> vexNum ; j ++ ) { if ( G -> arcs [ min ] [ j ] < edge [ j ] . weight ) { edge [ j ] . weight = G -> arcs [ min ] [ j ] ; edge [ j ] . vex = G -> vexs [ min ] ; } } } }
prim
 @param G the pointer of graph
 @param index the index of you visited
prim @param G the pointer of graph @param index the index of you visited