2

I have a graph. One can see that the complect subgraph A<->B<->C and E<->D<->F (pattern) occurs twice in the graph. I found the motifs and took 1st and 7th motifs from the list of igraphs.

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

I have a solution by hand selection motifs[[1]], motifs[[7]].

Question.

How to find the vertex lists of the pattern subgraph (for example, complect subgraph) automatically?

Nick
  • 1,086
  • 7
  • 21
  • I removed my solution as I realised something unstable in it. In any case, it is still not entirely clear what you mean by matching or "In graph can be occurred some triads and I need to color them". – Julius Vainora Nov 18 '18 at 02:23
  • 1
    If you want the equivalent of motifs, use `subgraph_isomorphisms` with the LAD method (look up how) and `induced=TRUE`. – Szabolcs Nov 19 '18 at 12:37
  • @Szabolcs, I have tried change iso <- subgraph_isomorphisms(pattern, graph) motifs <- lapply(iso, function (x) { induced_subgraph(graph, x) }) on the iso <- subgraph_isomorphisms(pattern, graph, methof="lad",induced=TRUE), but I have 12 lists of motifs again. , – Nick Nov 19 '18 at 16:16

0 Answers0