如何在原始图中找到模式子图?

时间:2018-11-17 03:02:26

标签: r igraph sna isomorphism

我有一个graph。可以看到,弯曲子图A<->B<->CE<->D<->Fpattern)在graph中出现了两次。我找到了motifs,并从igraph列表中选取了第一和第七个主题。

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")

enter image description here

我有一个手动选择motifs[[1]]motifs[[7]]的解决方案。

问题。

如何自动查找图案子图(例如,complect子图)的顶点列表?

0 个答案:

没有答案