16 | | All graphs (i.e., networks) have an associated Sage |
17 | | graphics object, which you can display:: |
| 16 | # Here's the point : |
| 17 | # |
| 18 | # we just have to insert the method's name in this file to add it to |
| 19 | # the tab, and in exchange the doc contains a table of width 3 with |
| 20 | # all methods listed, so that the reading order is Column1, then |
| 21 | # Column2, then Column3. Doing this by hand is hell with Sphinx when |
| 22 | # you need to insert a new method inside of the list ! |
23 | | If you create a graph in Sage using the ``Graph`` |
24 | | command, then plot that graph, the positioning of nodes is |
25 | | determined using the spring-layout algorithm. For the special graph |
26 | | constructors, which you get using ``graphs.[tab]``, the |
27 | | positions are preset. For example, consider the Petersen graph with |
28 | | default node positioning vs. the Petersen graph constructed by this |
29 | | database:: |
| 31 | h = (len(methods)+2)//3 |
| 32 | # Reorders the list of methods for horizontal reading, the only one Sphinx understands |
| 33 | reordered_methods = [0]*3*h |
| 34 | for i, m in enumerate(methods): |
| 35 | reordered_methods[3*(i%h)+(i//h)] = m |
| 36 | methods = reordered_methods |
31 | | sage: petersen_spring = Graph({0:[1,4,5], 1:[0,2,6], 2:[1,3,7], 3:[2,4,8], 4:[0,3,9], 5:[0,7,8], 6:[1,8,9], 7:[2,5,9], 8:[3,5,6], 9:[4,6,7]}) |
32 | | sage: petersen_spring.show() # long time |
33 | | sage: petersen_database = graphs.PetersenGraph() |
34 | | sage: petersen_database.show() # long time |
| 38 | # Adding the list to the __doc__ string |
| 39 | wrap_name = lambda x : ":meth:`"+str(x)+" <GraphGenerators."+str(x)+">`" if x else "" |
| 40 | while methods: |
| 41 | a = methods.pop(0) |
| 42 | b = methods.pop(0) |
| 43 | c = methods.pop(0) |
| 44 | __doc__ += " "+wrap_name(a)+" | "+wrap_name(b)+" | "+wrap_name(c)+"\n" |
40 | | For further visual examples and explanation, see the docstrings |
41 | | below, particularly for |
42 | | :meth:`CycleGraph <GraphGenerators.CycleGraph>`, |
43 | | :meth:`StarGraph <GraphGenerators.StarGraph>`, |
44 | | :meth:`WheelGraph <GraphGenerators.WheelGraph>`, |
45 | | :meth:`CompleteGraph <GraphGenerators.CompleteGraph>`, and |
46 | | :meth:`CompleteBipartiteGraph <GraphGenerators.CompleteBipartiteGraph>`. |
| 50 | __append_to_doc( |
| 51 | ["BarbellGraph", |
| 52 | "BuckyBall", |
| 53 | "BullGraph", |
| 54 | "ButterflyGraph", |
| 55 | "CircularLadderGraph", |
| 56 | "ClawGraph", |
| 57 | "CycleGraph", |
| 58 | "DiamondGraph", |
| 59 | "EmptyGraph", |
| 60 | "Grid2dGraph", |
| 61 | "GridGraph", |
| 62 | "HouseGraph", |
| 63 | "HouseXGraph", |
| 64 | "KrackhardtKiteGraph", |
| 65 | "LadderGraph", |
| 66 | "LollipopGraph", |
| 67 | "PathGraph", |
| 68 | "StarGraph", |
| 69 | "ToroidalGrid2dGraph", |
| 70 | "Toroidal6RegularGrid2dGraph", |
| 71 | "WheelGraph"] |
| 72 | ) |
59 | | - :meth:`BarbellGraph <GraphGenerators.BarbellGraph>` |
60 | | - :meth:`BuckyBall <GraphGenerators.BuckyBall>` |
61 | | - :meth:`BullGraph <GraphGenerators.BullGraph>` |
62 | | - :meth:`ButterflyGraph <GraphGenerators.ButterflyGraph>` |
63 | | - :meth:`CircularLadderGraph <GraphGenerators.CircularLadderGraph>` |
64 | | - :meth:`ClawGraph <GraphGenerators.ClawGraph>` |
65 | | - :meth:`CycleGraph <GraphGenerators.CycleGraph>` |
66 | | - :meth:`DiamondGraph <GraphGenerators.DiamondGraph>` |
67 | | - :meth:`EmptyGraph <GraphGenerators.EmptyGraph>` |
68 | | - :meth:`Grid2dGraph <GraphGenerators.Grid2dGraph>` |
69 | | - :meth:`GridGraph <GraphGenerators.GridGraph>` |
70 | | - :meth:`HouseGraph <GraphGenerators.HouseGraph>` |
71 | | - :meth:`HouseXGraph <GraphGenerators.HouseXGraph>` |
72 | | - :meth:`KrackhardtKiteGraph <GraphGenerators.KrackhardtKiteGraph>` |
73 | | - :meth:`LadderGraph <GraphGenerators.LadderGraph>` |
74 | | - :meth:`LollipopGraph <GraphGenerators.LollipopGraph>` |
75 | | - :meth:`PathGraph <GraphGenerators.PathGraph>` |
76 | | - :meth:`StarGraph <GraphGenerators.StarGraph>` |
77 | | - :meth:`ToroidalGrid2dGraph <GraphGenerators.ToroidalGrid2dGraph>` |
78 | | - :meth:`Toroidal6RegularGrid2dGraph <GraphGenerators.Toroidal6RegularGrid2dGraph>` |
79 | | - :meth:`WheelGraph <GraphGenerators.WheelGraph>` |
| 134 | __doc__ += """ |
| 135 | **Families of graphs** |
| 136 | """ |
93 | | - :meth:`Balaban10Cage <GraphGenerators.Balaban10Cage>` |
94 | | - :meth:`Balaban11Cage <GraphGenerators.Balaban11Cage>` |
95 | | - :meth:`BidiakisCube <GraphGenerators.BidiakisCube>` |
96 | | - :meth:`BiggsSmithGraph <GraphGenerators.BiggsSmithGraph>` |
97 | | - :meth:`BrinkmannGraph <GraphGenerators.BrinkmannGraph>` |
98 | | - :meth:`ChvatalGraph <GraphGenerators.ChvatalGraph>` |
99 | | - :meth:`ClebschGraph <GraphGenerators.ClebschGraph>` |
100 | | - :meth:`CoxeterGraph <GraphGenerators.CoxeterGraph>` |
101 | | - :meth:`DoubleStarSnark <GraphGenerators.DoubleStarSnark>` |
102 | | - :meth:`DesarguesGraph <GraphGenerators.DesarguesGraph>` |
103 | | - :meth:`DurerGraph <GraphGenerators.DurerGraph>` |
104 | | - :meth:`DyckGraph <GraphGenerators.DyckGraph>` |
105 | | - :meth:`EllinghamHorton54Graph <GraphGenerators.EllinghamHorton54Graph>` |
106 | | - :meth:`EllinghamHorton78Graph <GraphGenerators.EllinghamHorton78Graph>` |
107 | | - :meth:`ErreraGraph <GraphGenerators.ErreraGraph>` |
108 | | - :meth:`FlowerSnark <GraphGenerators.FlowerSnark>` |
109 | | - :meth:`FosterGraph <GraphGenerators.FosterGraph>` |
110 | | - :meth:`FranklinGraph <GraphGenerators.FranklinGraph>` |
111 | | - :meth:`FruchtGraph <GraphGenerators.FruchtGraph>` |
112 | | - :meth:`GoldnerHararyGraph <GraphGenerators.GoldnerHararyGraph>` |
113 | | - :meth:`GrayGraph <GraphGenerators.GrayGraph>` |
114 | | - :meth:`GrotzschGraph <GraphGenerators.GrotzschGraph>` |
115 | | - :meth:`HallJankoGraph <GraphGenerators.HallJankoGraph>` |
116 | | - :meth:`HararyGraph <GraphGenerators.HararyGraph>` |
117 | | - :meth:`HarriesGraph <GraphGenerators.HarriesGraph>` |
118 | | - :meth:`HarriesWongGraph <GraphGenerators.HarriesWongGraph>` |
119 | | - :meth:`HeawoodGraph <GraphGenerators.HeawoodGraph>` |
120 | | - :meth:`HerschelGraph <GraphGenerators.HerschelGraph>` |
121 | | - :meth:`HigmanSimsGraph <GraphGenerators.HigmanSimsGraph>` |
122 | | - :meth:`HoffmanSingletonGraph <GraphGenerators.HoffmanSingletonGraph>` |
123 | | - :meth:`HoffmanGraph <GraphGenerators.HoffmanGraph>` |
124 | | - :meth:`HoltGraph <GraphGenerators.HoltGraph>` |
125 | | - :meth:`LjubljanaGraph <GraphGenerators.LjubljanaGraph>` |
126 | | - :meth:`McGeeGraph <GraphGenerators.McGeeGraph>` |
127 | | - :meth:`MoebiusKantorGraph <GraphGenerators.MoebiusKantorGraph>` |
128 | | - :meth:`MoserSpindle <GraphGenerators.MoserSpindle>` |
129 | | - :meth:`NauruGraph <GraphGenerators.NauruGraph>` |
130 | | - :meth:`PappusGraph <GraphGenerators.PappusGraph>` |
131 | | - :meth:`PetersenGraph <GraphGenerators.PetersenGraph>` |
132 | | - :meth:`ShrikhandeGraph <GraphGenerators.ShrikhandeGraph>` |
133 | | - :meth:`ThomsenGraph <GraphGenerators.ThomsenGraph>` |
134 | | - :meth:`Tutte12Cage <GraphGenerators.Tutte12Cage>` |
135 | | - :meth:`TutteCoxeterGraph <GraphGenerators.TutteCoxeterGraph>` |
136 | | - :meth:`WagnerGraph <GraphGenerators.WagnerGraph>` |
| 176 | __doc__ += """ |
| 177 | **Pseudofractal graphs** |
| 178 | """ |
142 | | - :meth:`BalancedTree <GraphGenerators.BalancedTree>` |
143 | | - :meth:`BubbleSortGraph <GraphGenerators.BubbleSortGraph>` |
144 | | - :meth:`CirculantGraph <GraphGenerators.CirculantGraph>` |
145 | | - :meth:`CompleteBipartiteGraph <GraphGenerators.CompleteBipartiteGraph>` |
146 | | - :meth:`CompleteGraph <GraphGenerators.CompleteGraph>` |
147 | | - :meth:`CubeGraph <GraphGenerators.CubeGraph>` |
148 | | - :meth:`FibonacciTree <GraphGenerators.FibonacciTree>` |
149 | | - :meth:`FriendshipGraph <GraphGenerators.FriendshipGraph>` |
150 | | - :meth:`FuzzyBallGraph <GraphGenerators.FuzzyBallGraph>` |
151 | | - :meth:`GeneralizedPetersenGraph <GraphGenerators.GeneralizedPetersenGraph>` |
152 | | - :meth:`HanoiTowerGraph <GraphGenerators.HanoiTowerGraph>` |
153 | | - :meth:`HyperStarGraph <GraphGenerators.HyperStarGraph>` |
154 | | - :meth:`IntervalGraph <GraphGenerators.IntervalGraph>` |
155 | | - :meth:`KneserGraph <GraphGenerators.KneserGraph>` |
156 | | - :meth:`LCFGraph <GraphGenerators.LCFGraph>` |
157 | | - :meth:`MycielskiGraph <GraphGenerators.MycielskiGraph>` |
158 | | - :meth:`MycielskiStep <GraphGenerators.MycielskiStep>` |
159 | | - :meth:`NKStarGraph <GraphGenerators.NKStarGraph>` |
160 | | - :meth:`NStarGraph <GraphGenerators.NStarGraph>` |
161 | | - :meth:`OddGraph <GraphGenerators.OddGraph>` |
162 | | - :meth:`PaleyGraph <GraphGenerators.PaleyGraph>` |
163 | | - :meth:`RingedTree <GraphGenerators.RingedTree>` |
164 | | - :meth:`line_graph_forbidden_subgraphs <GraphGenerators.line_graph_forbidden_subgraphs>` |
165 | | - :meth:`PermutationGraph <GraphGenerators.PermutationGraph>` |
166 | | - :meth:`trees <GraphGenerators.trees>` |
| 186 | __append_to_doc( |
| 187 | ["RandomBarabasiAlbert", |
| 188 | "RandomBipartite", |
| 189 | "RandomGNM", |
| 190 | "RandomGNP", |
| 191 | "RandomHolmeKim", |
| 192 | "RandomInterval", |
| 193 | "RandomLobster", |
| 194 | "RandomNewmanWattsStrogatz", |
| 195 | "RandomRegular", |
| 196 | "RandomShell", |
| 197 | "RandomTree", |
| 198 | "RandomTreePowerlaw"]) |
181 | | Random graphs |
182 | | ------------- |
183 | | |
184 | | - :meth:`RandomBarabasiAlbert <GraphGenerators.RandomBarabasiAlbert>` |
185 | | - :meth:`RandomBipartite <GraphGenerators.RandomBipartite>` |
186 | | - :meth:`RandomGNM <GraphGenerators.RandomGNM>` |
187 | | - :meth:`RandomGNP <GraphGenerators.RandomGNP>` |
188 | | - :meth:`RandomHolmeKim <GraphGenerators.RandomHolmeKim>` |
189 | | - :meth:`RandomInterval <GraphGenerators.RandomInterval>` |
190 | | - :meth:`RandomLobster <GraphGenerators.RandomLobster>` |
191 | | - :meth:`RandomNewmanWattsStrogatz <GraphGenerators.RandomNewmanWattsStrogatz>` |
192 | | - :meth:`RandomRegular <GraphGenerators.RandomRegular>` |
193 | | - :meth:`RandomShell <GraphGenerators.RandomShell>` |
194 | | - :meth:`RandomTree <GraphGenerators.RandomTree>` |
195 | | - :meth:`RandomTreePowerlaw <GraphGenerators.RandomTreePowerlaw>` |
196 | | |
197 | | |
198 | | Graphs with a given degree sequence |
199 | | ----------------------------------- |
200 | | |
201 | | - :meth:`DegreeSequence <GraphGenerators.DegreeSequence>` |
202 | | - :meth:`DegreeSequenceBipartite <GraphGenerators.DegreeSequenceBipartite>` |
203 | | - :meth:`DegreeSequenceConfigurationModel <GraphGenerators.DegreeSequenceConfigurationModel>` |
204 | | - :meth:`DegreeSequenceExpected <GraphGenerators.DegreeSequenceExpected>` |
205 | | - :meth:`DegreeSequenceTree <GraphGenerators.DegreeSequenceTree>` |
206 | | |
207 | | |
208 | | Miscellaneous |
209 | | ------------- |
210 | | |
211 | | - :meth:`WorldMap <GraphGenerators.WorldMap>` |
212 | | |
| 219 | __doc__ += """ |