ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 13 Apr 2019 18:37:28 -0500Find copy of subgraph and check if graph induced by neighborhood of particular vertex is bipartitehttp://ask.sagemath.org/question/46149/find-copy-of-subgraph-and-check-if-graph-induced-by-neighborhood-of-particular-vertex-is-bipartite/I asked Sage to generate all graphs on 7 vertices and 12 edges with clique number 4 using the command
g7_4=[g for g in graphs.nauty_geng('7 12') if g.clique_number()==4]
Next I defined a graph H as follows:
H=graphs.CompleteGraph(4)
H.add_edges([(4,0), (4,1), (4,5)])
For every induced isomorphic copy H' of H in each graph g in g7_4 I want Sage to find out if the subgraph induced by the neighborhood of the isomorphic copy in H' of the vertex labeled 4 in H is bipartite or not.
The issue here is that I want to target the vertex in H' that plays the role of 4 in H, but I can't figure out how to do that.
Here is my feeble attempt:
for g in g7_4:
for p in g.subgraph_search_iterator(H,induced=True): #for each induced isomorphic copy of H in g
N=p.subgraph(Set(H.neighbors(4))) #let N be subgraph induced by neighborhood of 4 (vertex from H)
if not N.is_bipartite():
print(g7_4.index(g), 'bipartite')
else:
print(g7_4.index(g), 'not bipartite')
Please help me with my code! I am still new to Sage. Thank you!merluzaSat, 13 Apr 2019 18:37:28 -0500http://ask.sagemath.org/question/46149/Building Graphs with Specific Properties Using Sagehttp://ask.sagemath.org/question/45944/building-graphs-with-specific-properties-using-sage/I would like to use Sage to build graphs with particular properties. I know how to call a program called "nauty" to ask Sage to generate, for example, all graphs on 8 vertices with 16 edges with clique number 4. However, I would like to add more properties.
Is it possible to have Sage generate all graphs with clique number 4 so that all vertices that are contained in a 4-clique satisfy a minimum degree condition? Or is it in general possible to have a particular subset of vertices satisfy a degree condition?
Thank you.merluzaFri, 29 Mar 2019 15:32:22 -0500http://ask.sagemath.org/question/45944/