我有一个二分图和一个数据框,每一行与图的第一面的每个顶点相关联。图形没有连接,当我找到图形的最大组件时,我必须对数据框进行子集化(这不会给我正确的答案)。另一种可能的选择是将数据框的行设置为图形第一面顶点的属性(我不知道该怎么做)!这是一个玩具示例:
edgelist = matrix(c("A","a","A","b","B","b","C","c","D","c"),ncol=2,byrow=T)
bg <- graph.data.frame(edgelist, directed=F)
V(bg)$type <- V(bg)$name %in% edgelist[,1]
summary(bg)
V(bg)[V(bg)$type==1]
df = data.frame(id=c("A","B","C","D"), x=runif(4,10,50), y=sample(4), z=rnorm(4))
gclust = clusters(bg)
numClust = gclust$no
numLCC = gclust$csize[1]
bg2 = induced.subgraph(bg, which(gclust$membership ==which.max(gclust$csize)))
remained_set1 <- V(bg2)[V(bg2)$type==1]
df[as.character(df[,1])%in%remained_set1,] # wrong answer
答案 0 :(得分:0)
尝试使用顶点的名称并翻转subset(df, id %in% names(remained_set1))
foreach (string dirPath in Directory.GetDirectories(sPath, "*",
SearchOption.AllDirectories))
Directory.CreateDirectory(dirPath.Replace(sPath, dPath));
foreach (string newPath in Directory.GetFiles(sPath, "*.*",
SearchOption.AllDirectories))
File.Copy(newPath, newPath.Replace(sPath, dPath), true);
这将返回示例中A和B的行。