我有一个graph
. 可以看到复杂子图A<->B<->C
和E<->D<->F
( pattern
) 在 中出现了两次graph
。我motifs
从 igraphs 列表中找到并取了第 1 个和第 7 个图案。
libraty(igraph)
el <- matrix( c("A", "B",
"A", "C",
"B", "A",
"B", "C",
"C", "A",
"C", "B",
"C", "E",
"E", "D",
"E", "F",
"D", "E",
"D", "F",
"F", "E",
"F", "D"),
nc = 2, byrow = TRUE)
graph <- graph_from_edgelist(el)
pattern <- graph.isocreate(size=3, number = 15, directed=TRUE)
iso <- subgraph_isomorphisms(pattern, graph)
motifs <- lapply(iso, function (x) { induced_subgraph(graph, x) })
V(graph)$id <- seq_len(vcount(graph))
V(graph)$color <- "white"
par(mfrow=c(1,2))
plot(graph, edge.curved=TRUE, main="Original graph")
m1 <- V(motifs[[1]])$id; m2 <- V(motifs[[7]])$id
V(graph)[m1]$color="red"; V(graph)[m2]$color="green"
plot(graph, edge.curved=TRUE, main="Highlight graph")
我有一个手工选择的解决方案motifs[[1]]
,motifs[[7]]
。
问题。
如何自动查找模式子图(例如,complect 子图)的顶点列表?