Repository: networkx/networkx
Pull request: doc: improve docstring for hypercube_graph.
Closes #7942

improving docstring for hypercube graph

Problem statement:
networkx.hypercube_graph documented as having nodes indexed by integers, actually uses n-tuples
<!-- If you have a general question about NetworkX, please use the discussions tab to create a new discussion -->

<!--- Provide a general summary of the issue in the Title above -->

### Current Behavior

<!--- Tell us what happens instead of the expected behavior -->

Graph returned by networkx.hypercube_graph is indexed with cartesian coordinate n-tuples, but documented as being indexed by integers 0..(2^n - 1)

### Expected Behavior

Index by integers.

or

Fix documentation

<!--- Tell us what should happen -->

### Steps to Reproduce

<!--- Provide a minimal example that reproduces the bug -->

### Environment

<!--- Please provide details about your local environment -->

Python version:
NetworkX version: 3.4.2

### Additional context

<!--- Add any other context about the problem here, screenshots, etc. -->

Hints from issue discussion:
I would like to work on this. Can I take it?
@hridyasadanand if you're asking me, sure!

Commit message: Touchups

Co-authored-by: Mridul Seth <mail@mriduls.com>

Patch to review:
diff --git a/networkx/generators/lattice.py b/networkx/generators/lattice.py
index 0617cd2bf7a..ba78da6db6b 100644
--- a/networkx/generators/lattice.py
+++ b/networkx/generators/lattice.py
@@ -145,25 +145,32 @@ def grid_graph(dim, periodic=False):
 
 @nx._dispatchable(graphs=None, returns_graph=True)
 def hypercube_graph(n):
-    """Returns the *n*-dimensional hypercube graph.
-
-    The nodes are the integers between 0 and ``2 ** n - 1``, inclusive.
-
-    For more information on the hypercube graph, see the Wikipedia
-    article `Hypercube graph`_.
+    """
+    Return the *n*-dimensional hypercube graph.
 
-    .. _Hypercube graph: https://en.wikipedia.org/wiki/Hypercube_graph
+    The *n*-dimensional hypercube graph [1]_ has ``2**n`` nodes, each represented as
+    a binary integer in the form of a tuple of 0's and 1's. Edges exist between
+    nodes that differ in exactly one bit.
 
     Parameters
     ----------
     n : int
-        The dimension of the hypercube.
-        The number of nodes in the graph will be ``2 ** n``.
+        Dimension of the hypercube, must be a positive integer.
 
     Returns
     -------
-    NetworkX graph
-        The hypercube graph of dimension *n*.
+    networkx.Graph
+        The n-dimensional hypercube graph as an undirected graph.
+
+    Examples
+    --------
+    >>> G = nx.hypercube_graph(3)
+    >>> list(G.neighbors((0, 0, 0)))
+    [(1, 0, 0), (0, 1, 0), (0, 0, 1)]
+
+    References
+    ----------
+    .. [1] https://en.wikipedia.org/wiki/Hypercube_graph
     """
     dim = n * [2]
     G = grid_graph(dim)


Code review comments:
diff_hunk: @@ -145,25 +145,32 @@ def grid_graph(dim, periodic=False):
 
 @nx._dispatchable(graphs=None, returns_graph=True)
 def hypercube_graph(n):
-    """Returns the *n*-dimensional hypercube graph.
-
-    The nodes are the integers between 0 and ``2 ** n - 1``, inclusive.
-
-    For more information on the hypercube graph, see the Wikipedia
-    article `Hypercube graph`_.
+    """
+    Return the *n*-dimensional hypercube graph.
path: networkx/generators/lattice.py
text: @user1:
Let's keep this matching the first line grammar and whitespace of the other functions in this module.
```suggestion
    """Returns the *n*-dimensional hypercube graph.
```