Skip to content

Commit

Permalink
sagemathgh-37045: Added third embedding in Cubegraph for oblique proj…
Browse files Browse the repository at this point in the history
…ection 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 sagemath#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: sagemath#37045
Reported by: Aman Moon
Reviewer(s): David Coudert
  • Loading branch information
Release Manager committed Jan 20, 2024
2 parents ca14fd5 + c39ca6f commit b4a9bad
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/sage/graphs/generators/families.py
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,13 @@ def CubeGraph(n, embedding=1):
vertices in each column represents rows in Pascal's triangle. See for
instance the :wikipedia:`10-cube` for more details.
- ``3``: oblique projection of the `n`-cube. Oblique projection involves
aligning one face parallel to the viewer and projecting at a specified
angle, maintaining equal size for edges parallel to one axis while
applying fixed foreshortening to others. This method simplifies the
representation of a four-dimensional hypercube onto a two-dimensional
plane, offering a geometrically consistent visualization.
- ``None`` or ``O``: no embedding is provided
EXAMPLES:
Expand Down Expand Up @@ -1214,15 +1221,20 @@ def CubeGraph(n, embedding=1):
sage: g.show(figsize=[12,12],vertex_labels=False, vertex_size=20) # long time, needs sage.plot
sage: g = graphs.CubeGraph(9, embedding=2)
sage: g.show(figsize=[12,12],vertex_labels=False, vertex_size=20) # long time, needs sage.plot
sage: g = graphs.CubeGraph(9, embedding=3)
sage: g.show(figsize=[12,12],vertex_labels=False, vertex_size=20) # long time, needs sage.plot
AUTHORS:
- Robert Miller
- David Coudert
"""
if embedding == 1:
if embedding == 1 or embedding == 3:
# construct recursively the adjacency dict and the embedding
theta = float(pi/n)
if embedding == 3 and n > 2:
theta = float(pi/(2*n-2))

d = {'': []}
dn = {}
p = {'': (float(0), float(0))}
Expand Down Expand Up @@ -3264,7 +3276,7 @@ def GeneralizedSierpinskiGraph(G, k, stretch=None):
- ``stretch`` -- integer (default: ``None``); stretching factor used to
determine the positions of the vertices of the output graph. By default
(``None``), this value is set to twice the maximum Euclidian distance
(``None``), this value is set to twice the maximum Euclidean distance
between the vertices of `G`. This parameter is used only when the vertices
of `G` have positions.
Expand Down

0 comments on commit b4a9bad

Please sign in to comment.