- 图
(1)邻接矩阵表示
typedef struct VertexType
{
int no;
char info;
};
typedef struct MGraph
{
int edges[size_max][size_max];
int n, e;
VertexType vex[size_max];
};
(2) 邻接表存储
typedef struct ArcNode
{
int adjvex;//该边所指向的结点的位置
struct ArcNode *nextarc;//指向下一条边的指针
int info;//该边的相关信息
};
typedef struct VNode
{
char data;//顶点信息
ArcNode *firstarc;//指向第一条边的指针
}VNode;
typedef struct AGRaph
{
VNode adjlist[size_max];//邻接表
int n, e;//顶点数和边数
};
(3) 顶点的度:与顶点V相关的边的条数;
入度:有向图中,指向顶点V的边的条数;
出度:有向图中,顶点V发出的边的条数;
(4) 有向完全图:有n(n-1)条边;
无向完全图:有n(n-1)/2条边;
(5) 路径长度:路径上边的数目;