Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有这张图:
df<-data.frame(x=c('a','b','c'),y=c('d','c','f')) g<-graph.data.frame(df,directed=F)
有没有办法根据它们所属的子图返回两个顶点列表?
我想得到这个输出:
vertex id 1 a 1 2 d 1 3 b 2 4 c 2 5 f 2
谢谢
见clusters。顺便提一句。您正在寻找的是图表的组成部分。(igraph 术语也令人困惑。)
clusters
data.frame(vertex=V(g)$name, id=clusters(g)$membership) # vertex id # 1 a 1 # 2 b 2 # 3 c 2 # 4 d 1 # 5 f 2