Skip to content

Commit b4a9bad

Browse files
author
Release Manager
committed
gh-37045: Added third embedding in Cubegraph for oblique projection of hypercubes Added third embedding for oblique projection of hypercube. **Output after changes:** `graphs.CubeGraph(3, 3).plot()` gives: ![tmp_zjbpqfvb](https://github.com/sagemath/sage/assets/125746010/71d400 da-2ec3-47bd-969c-2254ba6db437) `graphs.CubeGraph(4, 3).plot()` gives: ![tmp_42b4cb_b](https://github.com/sagemath/sage/assets/125746010/56e6a1 93-e12a-498b-95c2-0d640f6737ec) Fixes #37040 ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. URL: #37045 Reported by: Aman Moon Reviewer(s): David Coudert
2 parents ca14fd5 + c39ca6f commit b4a9bad

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/sage/graphs/generators/families.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,13 @@ def CubeGraph(n, embedding=1):
11801180
vertices in each column represents rows in Pascal's triangle. See for
11811181
instance the :wikipedia:`10-cube` for more details.
11821182
1183+
- ``3``: oblique projection of the `n`-cube. Oblique projection involves
1184+
aligning one face parallel to the viewer and projecting at a specified
1185+
angle, maintaining equal size for edges parallel to one axis while
1186+
applying fixed foreshortening to others. This method simplifies the
1187+
representation of a four-dimensional hypercube onto a two-dimensional
1188+
plane, offering a geometrically consistent visualization.
1189+
11831190
- ``None`` or ``O``: no embedding is provided
11841191
11851192
EXAMPLES:
@@ -1214,15 +1221,20 @@ def CubeGraph(n, embedding=1):
12141221
sage: g.show(figsize=[12,12],vertex_labels=False, vertex_size=20) # long time, needs sage.plot
12151222
sage: g = graphs.CubeGraph(9, embedding=2)
12161223
sage: g.show(figsize=[12,12],vertex_labels=False, vertex_size=20) # long time, needs sage.plot
1224+
sage: g = graphs.CubeGraph(9, embedding=3)
1225+
sage: g.show(figsize=[12,12],vertex_labels=False, vertex_size=20) # long time, needs sage.plot
12171226
12181227
AUTHORS:
12191228
12201229
- Robert Miller
12211230
- David Coudert
12221231
"""
1223-
if embedding == 1:
1232+
if embedding == 1 or embedding == 3:
12241233
# construct recursively the adjacency dict and the embedding
12251234
theta = float(pi/n)
1235+
if embedding == 3 and n > 2:
1236+
theta = float(pi/(2*n-2))
1237+
12261238
d = {'': []}
12271239
dn = {}
12281240
p = {'': (float(0), float(0))}
@@ -3264,7 +3276,7 @@ def GeneralizedSierpinskiGraph(G, k, stretch=None):
32643276
32653277
- ``stretch`` -- integer (default: ``None``); stretching factor used to
32663278
determine the positions of the vertices of the output graph. By default
3267-
(``None``), this value is set to twice the maximum Euclidian distance
3279+
(``None``), this value is set to twice the maximum Euclidean distance
32683280
between the vertices of `G`. This parameter is used only when the vertices
32693281
of `G` have positions.
32703282

0 commit comments

Comments
 (0)