1

我有一个像这样的 CSV 格式(表示图的邻接矩阵):

0,0,3.16023,7.98319,4.97476,0,0,7.5256,0,3.61683
0,0,0,0,6.66346,3.78653,0,0,0,5.28698
3.16023,0,0,9.30634,0,0,0,0,6.97926,6.94043
7.98319,0,9.30634,0,7.83085,0,0,6.32612,3.90679,0
4.97476,6.66346,0,7.83085,0,1.72829,4.3236,0,9.29742,0
0,3.78653,0,0,1.72829,0,5.51931,0,0,1.70871
0,0,0,0,4.3236,5.51931,0,0,9.81537,0
7.5256,0,0,6.32612,0,0,0,0,4.16524,0
0,0,6.97926,3.90679,9.29742,0,9.81537,4.16524,0,5.78895
3.61683,5.28698,6.94043,0,0,1.70871,0,0,5.78895,0

我使用 R 和 igraph 库来绘制它。

library(igraph)
mygraph=read.csv("graph.csv", header=FALSE)
M <- as.matrix(mygraph)
g <- graph.adjacency(adjmatrix=M, mode="undirected", weighted=TRUE, diag=FALSE)
plot(g)

如何打印边缘长度/重量?该图 ( http://i.stack.imgur.com/X6pkw.png ) 绘制时没有边长。如何在绘图内打印边缘长度?

4

1 回答 1

2
plot(g, edge.label=round(E(g)$weight, 3))

?igraph.plotting手册。

于 2013-11-07T03:47:47.887 回答