Ask Your Question

How can I search and count all induced subgraphs in a directed graph with edge labels?

asked 2015-04-23 05:29:44 -0500

bssteniss gravatar image

updated 2015-04-27 03:45:36 -0500

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)

While it should return 1 not 2.

edit retag flag offensive close merge delete


Welcome 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.

slelievre gravatar imageslelievre ( 2015-04-24 02:34:32 -0500 )edit

Thanks. it's done.

bssteniss gravatar imagebssteniss ( 2015-04-27 04:05:13 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-04-24 04:39:25 -0500

Nathann gravatar image
edit flag offensive delete link more


Hello 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?

bssteniss gravatar imagebssteniss ( 2015-04-27 04:06:53 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2015-04-23 05:29:44 -0500

Seen: 413 times

Last updated: Apr 27 '15