Skip to content

Commit

Permalink
DOC: Link methods in functions to base Graph methods/properties (#7125)
Browse files Browse the repository at this point in the history
* DOC: Link methods in functions to base Graph methods/properties

* make it pretty
  • Loading branch information
MridulS committed Nov 22, 2023
1 parent bbdc3f0 commit f93f0e2
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions networkx/classes/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@


def nodes(G):
"""Returns an iterator over the graph nodes."""
"""Returns a NodeView over the graph nodes.
This function wraps the :func:`G.nodes <networkx.Graph.nodes>` property.
"""
return G.nodes()


Expand All @@ -59,29 +62,42 @@ def edges(G, nbunch=None):
Return all edges if nbunch is unspecified or nbunch=None.
For digraphs, edges=out_edges
This function wraps the :func:`G.edges <networkx.Graph.edges>` property.
"""
return G.edges(nbunch)


def degree(G, nbunch=None, weight=None):
"""Returns a degree view of single node or of nbunch of nodes.
If nbunch is omitted, then return degrees of *all* nodes.
This function wraps the :func:`G.degree <networkx.Graph.degree>` property.
"""
return G.degree(nbunch, weight)


def neighbors(G, n):
"""Returns a list of nodes connected to node n."""
"""Returns an iterator over all neighbors of node n.
This function wraps the :func:``G.neighbors <networkx.Graph.neighbors>` function.
"""
return G.neighbors(n)


def number_of_nodes(G):
"""Returns the number of nodes in the graph."""
"""Returns the number of nodes in the graph.
This function wraps the :func:`G.number_of_nodes <networkx.Graph.number_of_nodes>` function.
"""
return G.number_of_nodes()


def number_of_edges(G):
"""Returns the number of edges in the graph."""
"""Returns the number of edges in the graph.
This function wraps the :func:`G.number_of_edges <networkx.Graph.number_of_edges>` function.
"""
return G.number_of_edges()


Expand Down

0 comments on commit f93f0e2

Please sign in to comment.