ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 27 Apr 2015 04:06:53 -0500How can I search and count all induced subgraphs in a directed graph with edge labels?https://ask.sagemath.org/question/26630/how-can-i-search-and-count-all-induced-subgraphs-in-a-directed-graph-with-edge-labels/Hello all,
I can extract all induced subgraphs and count them in a graph. My question is how I can search and count all induced subgraphs in a labeled graph (a graph with edge labels)? In documentation of g.subgraph() and g.subgraph_search_count() is mentioned that these functions should work on labeled graphs as well. but it does not work. Here is an example:
sage: g=DiGraph()
sage: g.add_vertex(0)
sage: g.add_vertex(1)
sage: g.add_vertex(2)
sage: g.add_edge(0,1,label="a")
sage: g.add_edge(1,2,label="b")
sage: g.plot(color_by_label="true")
sage: g.plot(color_by_label=true)
sage: s=DiGraph()
sage: s.add_vertex(0)
sage: s.add_vertex(1)
sage: s.add_edge(0,1,label="a")
sage: s.plot(color_by_label=true)
sage: g.subgraph_search_count(s)
2
While it should return 1 not 2.
Thu, 23 Apr 2015 05:29:44 -0500https://ask.sagemath.org/question/26630/how-can-i-search-and-count-all-induced-subgraphs-in-a-directed-graph-with-edge-labels/Comment by bssteniss for <p>Hello all,</p>
<p>I can extract all induced subgraphs and count them in a graph. My question is how I can search and count all induced subgraphs in a labeled graph (a graph with edge labels)? In documentation of g.subgraph() and g.subgraph_search_count() is mentioned that these functions should work on labeled graphs as well. but it does not work. Here is an example:</p>
<pre><code>sage: g=DiGraph()
sage: g.add_vertex(0)
sage: g.add_vertex(1)
sage: g.add_vertex(2)
sage: g.add_edge(0,1,label="a")
sage: g.add_edge(1,2,label="b")
sage: g.plot(color_by_label="true")
sage: g.plot(color_by_label=true)
sage: s=DiGraph()
sage: s.add_vertex(0)
sage: s.add_vertex(1)
sage: s.add_edge(0,1,label="a")
sage: s.plot(color_by_label=true)
sage: g.subgraph_search_count(s)
2
</code></pre>
<p>While it should return 1 not 2. </p>
https://ask.sagemath.org/question/26630/how-can-i-search-and-count-all-induced-subgraphs-in-a-directed-graph-with-edge-labels/?comment=26655#post-id-26655Thanks. it's done.Mon, 27 Apr 2015 04:05:13 -0500https://ask.sagemath.org/question/26630/how-can-i-search-and-count-all-induced-subgraphs-in-a-directed-graph-with-edge-labels/?comment=26655#post-id-26655Comment by slelievre for <p>Hello all,</p>
<p>I can extract all induced subgraphs and count them in a graph. My question is how I can search and count all induced subgraphs in a labeled graph (a graph with edge labels)? In documentation of g.subgraph() and g.subgraph_search_count() is mentioned that these functions should work on labeled graphs as well. but it does not work. Here is an example:</p>
<pre><code>sage: g=DiGraph()
sage: g.add_vertex(0)
sage: g.add_vertex(1)
sage: g.add_vertex(2)
sage: g.add_edge(0,1,label="a")
sage: g.add_edge(1,2,label="b")
sage: g.plot(color_by_label="true")
sage: g.plot(color_by_label=true)
sage: s=DiGraph()
sage: s.add_vertex(0)
sage: s.add_vertex(1)
sage: s.add_edge(0,1,label="a")
sage: s.plot(color_by_label=true)
sage: g.subgraph_search_count(s)
2
</code></pre>
<p>While it should return 1 not 2. </p>
https://ask.sagemath.org/question/26630/how-can-i-search-and-count-all-induced-subgraphs-in-a-directed-graph-with-edge-labels/?comment=26634#post-id-26634Welcome to ask-sage! To display code lines, either (a) select the code lines and press the "code" button (the one with '101 010') or (b) indent these lines by 4 spaces. Try editing your question to do that.Fri, 24 Apr 2015 02:34:32 -0500https://ask.sagemath.org/question/26630/how-can-i-search-and-count-all-induced-subgraphs-in-a-directed-graph-with-edge-labels/?comment=26634#post-id-26634Answer by bssteniss for <p>Hello all,</p>
<p>I can extract all induced subgraphs and count them in a graph. My question is how I can search and count all induced subgraphs in a labeled graph (a graph with edge labels)? In documentation of g.subgraph() and g.subgraph_search_count() is mentioned that these functions should work on labeled graphs as well. but it does not work. Here is an example:</p>
<pre><code>sage: g=DiGraph()
sage: g.add_vertex(0)
sage: g.add_vertex(1)
sage: g.add_vertex(2)
sage: g.add_edge(0,1,label="a")
sage: g.add_edge(1,2,label="b")
sage: g.plot(color_by_label="true")
sage: g.plot(color_by_label=true)
sage: s=DiGraph()
sage: s.add_vertex(0)
sage: s.add_vertex(1)
sage: s.add_edge(0,1,label="a")
sage: s.plot(color_by_label=true)
sage: g.subgraph_search_count(s)
2
</code></pre>
<p>While it should return 1 not 2. </p>
https://ask.sagemath.org/question/26630/how-can-i-search-and-count-all-induced-subgraphs-in-a-directed-graph-with-edge-labels/?answer=26656#post-id-26656Hello Nathann,
Thank you for your comments and follow up for creating a ticket. Apparently the text of the documentation is already changed. Just, how can I search induced subgraphs in labeled graphs? This is the main problem. Are there any methods or suggestions which help me to do that?
Regards
Mohsen Mon, 27 Apr 2015 04:06:06 -0500https://ask.sagemath.org/question/26630/how-can-i-search-and-count-all-induced-subgraphs-in-a-directed-graph-with-edge-labels/?answer=26656#post-id-26656Answer by Nathann for <p>Hello all,</p>
<p>I can extract all induced subgraphs and count them in a graph. My question is how I can search and count all induced subgraphs in a labeled graph (a graph with edge labels)? In documentation of g.subgraph() and g.subgraph_search_count() is mentioned that these functions should work on labeled graphs as well. but it does not work. Here is an example:</p>
<pre><code>sage: g=DiGraph()
sage: g.add_vertex(0)
sage: g.add_vertex(1)
sage: g.add_vertex(2)
sage: g.add_edge(0,1,label="a")
sage: g.add_edge(1,2,label="b")
sage: g.plot(color_by_label="true")
sage: g.plot(color_by_label=true)
sage: s=DiGraph()
sage: s.add_vertex(0)
sage: s.add_vertex(1)
sage: s.add_edge(0,1,label="a")
sage: s.plot(color_by_label=true)
sage: g.subgraph_search_count(s)
2
</code></pre>
<p>While it should return 1 not 2. </p>
https://ask.sagemath.org/question/26630/how-can-i-search-and-count-all-induced-subgraphs-in-a-directed-graph-with-edge-labels/?answer=26636#post-id-26636see https://groups.google.com/d/topic/sage-support/CTeSnBZN7Sc/discussionFri, 24 Apr 2015 04:39:25 -0500https://ask.sagemath.org/question/26630/how-can-i-search-and-count-all-induced-subgraphs-in-a-directed-graph-with-edge-labels/?answer=26636#post-id-26636Comment by bssteniss for <p>see <a href="https://groups.google.com/d/topic/sage-support/CTeSnBZN7Sc/discussion">https://groups.google.com/d/topic/sag...</a></p>
https://ask.sagemath.org/question/26630/how-can-i-search-and-count-all-induced-subgraphs-in-a-directed-graph-with-edge-labels/?comment=26657#post-id-26657Hello Nathann,
Thank you for your comments and follow up for creating a ticket. Apparently the text of the documentation is already changed. Just, how can I search induced subgraphs in labeled graphs? This is the main problem. Are there any method or suggestion which helps me to do that?Mon, 27 Apr 2015 04:06:53 -0500https://ask.sagemath.org/question/26630/how-can-i-search-and-count-all-induced-subgraphs-in-a-directed-graph-with-edge-labels/?comment=26657#post-id-26657