This is pseudo code in C.
void prim(G, W, start){
// G: adjacency matrix
// W: the weight set of edges in graph
// start: the start point
// initial
struct vertex node[NUM_NODES];
for (int u = 0; u < NUM_NODES, u++){
node[u].key = INT_MAX;
node[u].pi = -1;
}
node[start].key = 0;
create_priority_queue(q, node); //依照key值放入頂點
// prim's
while(!IsEmpty(q)){
int u = dequeue(q);
for (int v = 0; v<NUM_NODES; v++){
//確認(u,v)邊存在,v在Queue中,(u,v)邊的權重小於v的key值
if (G[u][v] == 1 && find(v) && W[u][v]<node[v].key){
node[v].pi = u;
node[v].key = W[u][v];
}
}
}
}