저는 Prim의 알고리즘을 C++과 행렬로 구현하려고합니다.Prim 's Algorithm with Matrices
int node[] = {11, 11, 0, 11, 11, 11, 11, 11};
int nodeCon[8];
void generatePrims() {
int cNode = 3;
for (int i = 1; i <= 8; i++) {
if (graph[cNode][i] != 0){
if (node[i] > graph[cNode][i]) {
node[i] = graph[cNode][i];
nodeCon[i] = cNode;
}
}
}
};
cNode가 시작 노드 :
여기 내 문제입니다.
graph[][]
은 연결을 유지하는 2 차원 행렬입니다.
nodeCon[]
node[]=
는 nodeCon 대한 비용 값을 유지를 보유 할 배열이다.
내 질문은 어떻게 다음 호프로 계속할 것인가? 최소 연결을 찾았고 루프가 어떻게 보이는지 값 cNode= minConnection
을 설정한다고 가정 해 봅시다. 내가 모든 노드를 검사했다는 것을 어떻게 알았습니까? 사전에
덕분에이 같은
참조 : [컴퓨팅 최소 스패닝 트리에 대한 프림의 알고리즘 (http://www.cprogramming.com/tutorial/computersciencetheory/mst.html) –