/顶点表中结点的结构 template<class T> struct Vertex { friend class Graph<T>; T VerName /顶点的名称 Edge*adjacent;/边链表的头指针 }
// 顶点表中结点的结构 template<class T> struct Vertex { friend class Graph<T> ; T VerName ; // 顶点的名称 Edge *adjacent ; // 边链表的头指针 }
//图的类定义 template<class T>class Graph private Vertex<T>head;/顶点表的头指针 int graphsize //当前顶点个数 int MaxGraphsize //最大顶点个数 int NumEdge;/当前边数 int MaxNumEdge /最大边数 /返回顶点vertex在顶点表中的序号 int GetVertexPos(const T &vertex )
// 图的类定义 template<class T> class Graph { private : Vertex<T> *head ; // 顶点表的头指针 int graphsize ; // 当前顶点个数 int MaxGraphsize ; // 最大顶点个数 int NumEdge ; // 当前边数 int MaxNumEdge ; // 最大边数 // 返回顶点vertex在顶点表中的序号 int GetVertexPos( const T &vertex ) ;
public Graph(int sz);//构造函数 ~Graph();//析构函数
public : Graph( int sz ) ; // 构造函数 ~Graph ( ) ; // 析构函数
//数据访问函数 /返回序号为v的顶点的第一个邻接顶点的序号 int GetFirstNeighbor(const int v); /返回序号为v1的顶点相对于序号为v2的顶点的 下一个邻接顶点的序号 int GetNextNeighbor(const int v1, const int v2 )
//数据访问函数 //返回序号为v的顶点的第一个邻接顶点的序号 int GetFirstNeighbor( const int v) ; //返回序号为v1的顶点相对于序号为v2的顶点的 下一个邻接顶点的序号 int GetNextNeighbor( const int v1 , const int v2 ) ;
/修改图的函数 /插入一个顶点 void InsertVertex(const T vertex); //插入一条边(v1l,v2),边权值为weight void InsertEdge(const T vertex1, const T vertex2,int weight);
//修改图的函数 //插入一个顶点 void InsertVertex( const T & vertex) ; //插入一条边(v1,v2),边权值为weight void InsertEdge( const T & vertex1 , const T & vertex2 ,int weight) ;