How to find the pattern subgraphs in original graph?












1















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?










share|improve this question

























  • 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 2: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


















1















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?










share|improve this question

























  • 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 2: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
















1












1








1


1






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?










share|improve this question
















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?







r igraph sna isomorphism






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 18 '18 at 9:29







Nick

















asked Nov 17 '18 at 3:02









NickNick

283112




283112













  • 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 2: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





















  • 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 2: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



















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 2:23





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 2:23




1




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







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







@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






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53347818%2fhow-to-find-the-pattern-subgraphs-in-original-graph%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53347818%2fhow-to-find-the-pattern-subgraphs-in-original-graph%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini