通过 R 中边的概率生成无向图

问题描述

是否有 R 函数用于生成边上有概率的无向图?我试图通过构建邻接矩阵(精度矩阵)[见附录]来生成一个非超自然数据集。首先,我应该生成一个随机图,它的成对边 (i,j) 遵循正态概率密度函数。 'igraph' 包引入了 'sample_fitness' 和 'sample_degseq' 函数,它们将概率应用于每个顶点的度数,而不是 i 和 j 顶点之间是否存在边。 谢谢大家

Liu,Lafferty and Wasserman (2009)

library(MASS)
library(Matrix)
library(philentropy)
library(qgraph)
library(igraph)
library(huge)
d=10
tmp=matrix(runif(2*d,0.5),d,2)
tmp=2*tmp
L=distance(tmp,method="euclidean")
s=0.125
prob=(1/sqrt(2*pi))*exp(-(L^2)/2*s)
prob=mat2vec(prob)
degs<-sample(0:(length(prob)-1),replace=TRUE,prob=prob)
for(i in 1:d){
if (degs[i]>4){degs[i]=4}
}
degs
if(sum(degs)%%2!=0){degs[1]<-degs[1]+1}
degs
g4 <-sample_degseq(degs,method="vl")
all(degree(g4)==degs)
plot(g4)
theta=as_adjacency_matrix(g4,type="both")
for(j in 1:d){
for(i in 1:d){
if(theta[i,j]==0)
omega[i,j]=0
else
omega[i,j]=0.245
}
}
diag(omega)=1

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)