# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1306692118 -7200
# Node ID 6b34125f52d1c54a84083b6672fe6f6d6edd40c6
# Parent f8bdf65336cfdc59771dca5141e5b96d72c1d57b
trac 11399 -- Some other embeddings for graph generators
diff -r f8bdf65336cf -r 6b34125f52d1 sage/graphs/graph_generators.py
a
|
b
|
|
1958 | 1958 | """ |
1959 | 1959 | import networkx |
1960 | 1960 | G = networkx.tetrahedral_graph() |
1961 | | return graph.Graph(G, name="Tetrahedron") |
| 1961 | return graph.Graph(G, name="Tetrahedron", pos = |
| 1962 | { 0 : (0, 0), |
| 1963 | 1 : (0, 1), |
| 1964 | 2 : (cos(3.5*pi/3), sin(3.5*pi/3)), |
| 1965 | 3 : (cos(5.5*pi/3), sin(5.5*pi/3))} |
| 1966 | ) |
1962 | 1967 | |
1963 | 1968 | def HexahedralGraph(self): |
1964 | 1969 | """ |
… |
… |
|
2052 | 2057 | """ |
2053 | 2058 | import networkx |
2054 | 2059 | G = networkx.octahedral_graph() |
2055 | | return graph.Graph(G, name="Octahedron") |
| 2060 | |
| 2061 | pos = {} |
| 2062 | r1 = 5 |
| 2063 | r2 = 1 |
| 2064 | for i,v in enumerate([0,1,2]): |
| 2065 | i = i + 0.75 |
| 2066 | pos[v] = (r1*cos(i*2*pi/3),r1*sin(i*2*pi/3)) |
| 2067 | |
| 2068 | for i,v in enumerate([4,3,5]): |
| 2069 | i = i + .25 |
| 2070 | pos[v] = (r2*cos(i*2*pi/3),r2*sin(i*2*pi/3)) |
| 2071 | |
| 2072 | |
| 2073 | return graph.Graph(G, name="Octahedron", pos=pos) |
2056 | 2074 | |
2057 | 2075 | def IcosahedralGraph(self): |
2058 | 2076 | """ |
… |
… |
|
2148 | 2166 | """ |
2149 | 2167 | import networkx |
2150 | 2168 | G = networkx.dodecahedral_graph() |
2151 | | return graph.Graph(G, name="Dodecahedron") |
| 2169 | |
| 2170 | pos = {} |
| 2171 | r1 = 7 |
| 2172 | r2 = 4.7 |
| 2173 | r3 = 3.8 |
| 2174 | r4 = 1.5 |
| 2175 | |
| 2176 | for i,v in enumerate([19,0,1,2,3]): |
| 2177 | i = i + .25 |
| 2178 | pos[v] = (r1*cos(i*2*pi/5),r1*sin(i*2*pi/5)) |
| 2179 | |
| 2180 | for i,v in enumerate([18,10,8,6,4]): |
| 2181 | i = i + .25 |
| 2182 | pos[v] = (r2*cos(i*2*pi/5),r2*sin(i*2*pi/5)) |
| 2183 | |
| 2184 | for i,v in enumerate([17,11,9,7,5]): |
| 2185 | i = i - .25 |
| 2186 | pos[v] = (r3*cos(i*2*pi/5),r3*sin(i*2*pi/5)) |
| 2187 | |
| 2188 | for i,v in enumerate([12,13,14,15,16]): |
| 2189 | i = i + .75 |
| 2190 | pos[v] = (r4*cos(i*2*pi/5),r4*sin(i*2*pi/5)) |
| 2191 | |
| 2192 | return graph.Graph(G, name="Dodecahedron", pos=pos) |
2152 | 2193 | |
2153 | 2194 | ####################################################################### |
2154 | 2195 | # Named Graphs |