1 | initial version |
You can have a look at the questions tagged graph_generation
for more details and explanations about the following, see https://ask.sagemath.org/questions/scope:all/sort:activity-desc/tags:graph_generation/page:1/
Hence, we can first generate all planar and $C_5$-free graphs with the graphs
generators (using the augment="edges"
option), and then filter the connected ones (the cost is not expensive since we already selected few graphs):
sage: C5 = graphs.CycleGraph(5)
sage: good_graphs = [g for g in graphs(6, property=lambda G: G.is_planar() and not C5.is_subgraph(G,induced=False), augment="edges") if g.is_connected()]
sage: len(good_graphs)
sage: for g in good_graphs:
....: show(g)
2 | No.2 Revision |
You can have a look at the questions tagged graph_generation
for more details and explanations about the following, see https://ask.sagemath.org/questions/scope:all/sort:activity-desc/tags:graph_generation/page:1/
Hence, we can first generate all planar and $C_5$-free graphs with the graphs
generators (using the augment="edges"
option), and then filter the connected ones (the cost is not expensive since we already selected few graphs):
sage: C5 = graphs.CycleGraph(5)
sage: good_graphs = [g for g in graphs(6, property=lambda G: G.is_planar() and not C5.is_subgraph(G,induced=False), C5.is_subgraph(G,induced=False, up_to_isomorphism=True ), augment="edges") if g.is_connected()]
sage: len(good_graphs)
43
sage: for g in good_graphs:
....: show(g)