生成一系列邻接矩阵

时间:2018-08-07 14:02:26

标签: r matrix graph adjacency-matrix

我正在尝试生成与标记的有向图相对应的一系列80个5X5邻接矩阵。我选择的方法是首先创建8个基本的未标记矩阵(G1-G8),然后将10个不同的名称和行名(A,B,C,D,E)应用于它们。如何编写一个函数将以下两个任务重复执行8 * 10次,最后得到80个不同的矩阵?

<script type="text/javascript" src="dist/js/app.min.js"></script>

我已经为每个G尝试了此尝试,但没有成功

G1<-c(0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
    MG1=matrix(G1, nrow=5,ncol=5,byrow=T)
    dimnames(MG1)=list(c("A","B","D","C","E"),c("A","B","D","C","E"))
    MG101<-MG1
    dimnames(MG1)=list(c("A","B","D","C","E"),c("A","B","D","C","E"))
    MG102<-MG1

谢谢

0 个答案:

没有答案