哪位高人能指点一下:什么是邻接矩阵

shieldhuang 2002-07-03 10:12:42

1)int i,j,n;

2)for(i=0;i<n;j++) //邻接矩阵清0
3)for(j=0;j<n;j++) g[i][j];

2)有点看不懂,不知是否书上的印刷错误

...全文
480 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
inetsurfer 2002-07-04
  • 打赏
  • 举报
回复
是离期数学中的一个概念
设G=<V,E>是一个简单图,它有n个结点V={v1,v2,.....,vn}则n阶方阵A(G)=(aij)称为G的邻接矩阵。其中
{1 vi邻接vj
aij={
{0 vi不邻接vj
www_fighter 2002-07-04
  • 打赏
  • 举报
回复
邻接矩阵是图的一种表是方法,可以用直接数组表示也可以用含有节点数组的链表表示。建议最好参考数据结构中图的部分。你的程序中
for(i=0;i<n;j++) //邻接矩阵清0
的意思可能就是清空节点数组。
关门兔 2002-07-04
  • 打赏
  • 举报
回复
是不是应该这样:
2)for(i=0;i<n; i ++) //邻接矩阵清0

而不是:
2)for(i=0;i<n; j ++) //邻接矩阵清0

书上错把 i 印成 j 了。
azure711 2002-07-04
  • 打赏
  • 举报
回复
上面的是邻接矩阵初始化
devez 2002-07-03
  • 打赏
  • 举报
回复
数据结构中毒的一种存储方式.用矩阵来表示途中各结点的关系.把相连的各结点在矩阵表示出来,分有向图和无向图的区别.去看看数据结构的数吧!
atlantis13579 2002-07-03
  • 打赏
  • 举报
回复

Adjacency Matrix
A second way to represent a graph utilized an adjacency matrix. This is a N by N array (N is the number of vertices). The i,j entry contains a 1 if the edge (i,j) is in the graph; otherwise it contains a 0. For an undirected graph, this matrix is symmetric.

This representation is easy to code. It's much less space efficient, especially for large, sparse graphs. Debugging is harder, as the matrix is large. Finding all the edges incident to a given vertex is fairly expensive (linear in the number of vertices), but checking if two vertices are adjacent is very quick. Adding and removing edges are also very inexpensive operations.

For weighted graphs, the value of the (i,j) entry is used to store the weight of the edge. For an unweighted multigraph, the (i,j) entry can maintain the number of edges between the vertices. For a weighted multigraph, it's harder to extend this.

Example
The sample undirected graph would be represented by the following adjacency matrix:

V1 V2 V3 V4 V5 V6

V1 0 0 1 0 0 1

V2 0 0 0 0 1 0

V3 1 0 0 1 0 1

V4 0 0 1 0 0 0

V5 0 1 0 0 0 0

V6 1 0 1 0 0 0


It is sometimes helpful to use the fact that the (i,j) entry of the adjacency matrix raised to the k-th power gives the number of paths from vertex i to vertex j consisting of exactly k edges.
LeeMaRS 2002-07-03
  • 打赏
  • 举报
回复
只给一行代码,没办法告诉你是对是错.
邻接矩阵是用来表示图的关系的,你可以看看数据结构.

69,381

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧