图的邻接(链)表表示法 Graph adjacency list representation

邻接

邻接点: 对于无向图G=(V,{E}),若边(v,v’)∈E,则v和v’互为邻接点

简单描述:两个顶点之间有边相连就叫做邻接。

无权图的邻接表表示(一)

An adjacency list represents a graph as an array of linked lists. The index of the array represents a vertex and each element in its linked list represents the other vertices that form an edge with the vertex.

data structures

struct node{
    int vertex;
    struct node* next;
};

struct Graph{
    int numVertices;
    struct node** adjLists;
};

带权重图的邻接表

https://www.cnblogs.com/Camilo/p/3923468.html
https://blog.csdn.net/weixin_34005042/article/details/85980677

在这里插入图片描述
图中
顶点表:数组,支持随机存取。索引为顶点 编号。邻接(链)表中又称作表头。
边表:里面的数字是与顶点相邻的顶点编号(从0开始,与数组索引对应)。它是每一个链中的除表头部分——图中箭头后面的部分。
以第0个顶点为例,v0与编号/索引为1、2、3 的顶点相邻,通过查数组可得顶点名称——v1、v2、v3。

数据结构: https://blog.csdn.net/ASCIIdragon/article/details/84635236

//边
typedef struct ArcNode{
	int Adjvex;  // 这个索引值是边表节点自己在数组中的索引值——表头中定点的索引值。以第0个顶点为例,它的值是1、2或者3。
	ArcNode* nextarc;   //指向下一个邻接点。  用于串连所有与表头某一节点相邻的所有顶点。
	int weight;  // 边的权重。 无权图无此项
}ArcNode;

//顶点
typedef struct VNode{
	char  data;              // 如: v1,  v2  
	ArcNode* firstarc;       //与该顶点相连的所有的边 。实际存储的是与表头中某一顶点相邻的顶点和顶点之间*“**边**”*的***权重***
}AdjList[MAX_VERTEX_NUM];

typedef struct {
    int V_num;
    adjList    VerticesList;			//  arr
} Graph;
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值