diff --git a/src/sage/graphs/generators/basic.py b/src/sage/graphs/generators/basic.py index e74859c7866..6ebad186e4d 100644 --- a/src/sage/graphs/generators/basic.py +++ b/src/sage/graphs/generators/basic.py @@ -608,6 +608,67 @@ def DiamondGraph(): edges = [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3)] return graph.Graph(edges, pos=pos_dict, name="Diamond Graph") +def GemGraph(): + """ + Return a gem graph with 5 nodes. + + A gem graph is a fan graph (4,1). + + PLOTTING: Upon construction, the position dictionary is filled to + override the spring-layout algorithm. By convention, the gem + graph is drawn as a gem, with the sharp part on the bottom. + + EXAMPLES: + + Construct and show a gem graph:: + + sage: g = graphs.GemGraph() + sage: g.show() # long time + """ + pos_dict = {0:(0.5,0),1:(0,0.75),2:(0.25,1),3:(0.75,1),4:(1,0.75)} + edges = [(0, 1), (0, 2), (0, 3), (0, 4), (1, 2), (2, 3), (3, 4)] + return graph.Graph(edges, pos=pos_dict, name="Gem Graph") + +def ForkGraph(): + """ + Return a fork graph with 5 nodes. + + A fork graph, sometimes also called chair graph, is 5 vertex tree. + + PLOTTING: Upon construction, the position dictionary is filled to + override the spring-layout algorithm. By convention, the fork + graph is drawn as a fork, with the sharp part on the bottom. + + EXAMPLES: + + Construct and show a fork graph:: + + sage: g = graphs.ForkGraph() + sage: g.show() # long time + """ + pos_dict = {0:(0,0),1:(1,0),2:(0,1),3:(1,1),4:(0,2)} + edges = [(0, 2), (2, 3), (3, 1), (2, 4)] + return graph.Graph(edges, pos=pos_dict, name="Fork Graph") + +def DartGraph(): + """ + Return a dart graph with 5 nodes. + + PLOTTING: Upon construction, the position dictionary is filled to + override the spring-layout algorithm. By convention, the dart + graph is drawn as a dart, with the sharp part on the bottom. + + EXAMPLES: + + Construct and show a dart graph:: + + sage: g = graphs.DartGraph() + sage: g.show() # long time + """ + pos_dict = {0:(0,1),1:(-1,0),2:(1,0),3:(0,-1),4:(0,0)} + edges = [(0, 1), (0, 2), (1, 4), (2, 4), (0, 4), (3, 4)] + return graph.Graph(edges, pos=pos_dict, name="Dart Graph") + def EmptyGraph(): """ Returns an empty graph (0 nodes and 0 edges). diff --git a/src/sage/graphs/graph_generators.py b/src/sage/graphs/graph_generators.py index e052476a52a..6cafb8aa463 100644 --- a/src/sage/graphs/graph_generators.py +++ b/src/sage/graphs/graph_generators.py @@ -67,6 +67,9 @@ def __append_to_doc(methods): "CompleteGraph", "CompleteMultipartiteGraph", "DiamondGraph", + "GemGraph", + "DartGraph", + "ForkGraph", "DipoleGraph", "EmptyGraph", "Grid2dGraph", @@ -1893,6 +1896,9 @@ def quadrangulations(self, order, minimum_degree=None, minimum_connectivity=None CompleteBipartiteGraph = staticmethod(basic.CompleteBipartiteGraph) CompleteMultipartiteGraph= staticmethod(basic.CompleteMultipartiteGraph) DiamondGraph = staticmethod(basic.DiamondGraph) + GemGraph = staticmethod(basic.GemGraph) + DartGraph = staticmethod(basic.DartGraph) + ForkGraph = staticmethod(basic.ForkGraph) EmptyGraph = staticmethod(basic.EmptyGraph) Grid2dGraph = staticmethod(basic.Grid2dGraph) GridGraph = staticmethod(basic.GridGraph) diff --git a/src/sage/graphs/graph_list.py b/src/sage/graphs/graph_list.py index 21f50b1c6de..376a5f7eabf 100644 --- a/src/sage/graphs/graph_list.py +++ b/src/sage/graphs/graph_list.py @@ -303,6 +303,9 @@ def show_graphs(graph_list, **kwds): sage: glist.append(graphs.BarbellGraph(7, 4)) sage: glist.append(graphs.CycleGraph(15)) sage: glist.append(graphs.DiamondGraph()) + sage: glist.append(graphs.GemGraph()) + sage: glist.append(graphs.DartGraph()) + sage: glist.append(graphs.ForkGraph()) sage: glist.append(graphs.HouseGraph()) sage: glist.append(graphs.HouseXGraph()) sage: glist.append(graphs.KrackhardtKiteGraph()) @@ -316,7 +319,7 @@ def show_graphs(graph_list, **kwds): Check that length is <= 20:: sage: len(glist) - 14 + 17 Show the graphs in a graphics array::