一、需求图Prim算法最小生成树
无向图中点与点之间,边上的数字表示权值。
二、实现Prim算法最小生成树
1.边的描述
定义边的对象时应有以下属性:这条边连接两端的点(nodeIndexA,nodeIndexB),边的权值,以及这条边是否被选中
//Edge.h
#ifndef _EDGE_H_
#define _EDGE_H_
class Edge{
public:
Edge(int nodeIndexA = 0, int nodeIndexB = 0, int weightValue = 0);
int m_iNodeIndexA;
int m_iNodeIndexB;
int m_iWeightValue;
bool m_bSelected;
};
#endif
//Edge.cpp
#include "Edge.h"
Edge::Edge(int nodeIndexA, int nodeIndexB, int weightValue){
m_iNodeIndexA = nodeIndexA;
m_iNodeIndexB = nodeIndexB;
m_iWeightValue = weightValue;
m_