Repository: networkx/networkx

Issue:
Intersphinx links to Networkx graph classes don't work
Suppose I set up a Sphinx build (outside of NetworkX) with `conf.py` contents

``` python
extensions = [
    'sphinx.ext.intersphinx',
]

intersphinx_mapping = {
    'networkx': ('https://networkx.readthedocs.io/en/latest', None),
}
```

and try to write an `index.rst` file with

``` rst
:class:`networkx.Graph`
```

Attempting to render this documentation with Sphinx yields the warning

``` sh
index.rst:14: WARNING: py:class reference target not found: networkx.Graph
```

This is because NetworkX generates the documentation for `networkx.Graph` as a _function_ instead of a _class_:

``` rst
.. autofunction:: Graph
```

This can be fixed in NetworkX by changing `autofunction` to `autoclass`. In the meantime, as a workaround, the referring documentation can use `:func:`networkx.Graph`` instead of `:class:`networkx.Graph``.

I remember bringing this up at some point but there was some reason why it was `autofunction`...

Intersphinx links to Networkx graph classes don't work
Suppose I set up a Sphinx build (outside of NetworkX) with `conf.py` contents

``` python
extensions = [
    'sphinx.ext.intersphinx',
]

intersphinx_mapping = {
    'networkx': ('https://networkx.readthedocs.io/en/latest', None),
}
```

and try to write an `index.rst` file with

``` rst
:class:`networkx.Graph`
```

Attempting to render this documentation with Sphinx yields the warning

``` sh
index.rst:14: WARNING: py:class reference target not found: networkx.Graph
```

This is because NetworkX generates the documentation for `networkx.Graph` as a _function_ instead of a _class_:

``` rst
.. autofunction:: Graph
```

This can be fixed in NetworkX by changing `autofunction` to `autoclass`. In the meantime, as a workaround, the referring documentation can use `:func:`networkx.Graph`` instead of `:class:`networkx.Graph``.

I remember bringing this up at some point but there was some reason why it was `autofunction`...



Discussion:

Resolving patch:
diff --git a/networkx/algorithms/shortest_paths/weighted.py b/networkx/algorithms/shortest_paths/weighted.py
--- a/networkx/algorithms/shortest_paths/weighted.py
+++ b/networkx/algorithms/shortest_paths/weighted.py
@@ -141,12 +141,13 @@ def dijkstra_path(G, source, target, weight='weight'):
     will find the shortest red path.
 
     The weight function can be used to include node weights.
-    ```
-    def func(u, v, d):
-        return G.node[u].get('node_weight', 1)/2 + \
-               G.node[v].get('node_weight', 1)/2 + \
-               d.get('weight', 1)
-    ```
+
+    >>> def func(u, v, d):
+    ...     node_u_wt = G.node[u].get('node_weight', 1)
+    ...     node_v_wt = G.node[v].get('node_weight', 1)
+    ...     edge_wt = d.get('weight', 1)
+    ...     return node_u_wt/2 + node_v_wt/2 + edge_wt
+
     In this example we take the average of start and end node
     weights of an edge and add it to the weight of the edge.
 
@@ -963,9 +964,9 @@ def bellman_ford(G, source, weight='weight'):
     """
     _warnings.warn("Function bellman_ford() is deprecated, use function bellman_ford_predecessor_and_distance() instead.",
                    DeprecationWarning)
-                   
-    return bellman_ford_predecessor_and_distance(G, source, weight=weight) 
-    
+
+    return bellman_ford_predecessor_and_distance(G, source, weight=weight)
+
 def bellman_ford_predecessor_and_distance(G, source, target=None, cutoff=None, weight='weight'):
     """Compute shortest path lengths and predecessors on shortest paths
     in weighted graphs.
@@ -1052,7 +1053,7 @@ def bellman_ford_predecessor_and_distance(G, source, target=None, cutoff=None, w
         return pred, dist
 
     weight = _weight_function(G, weight)
-        
+
     return (pred, _bellman_ford(G, [source], weight,pred=pred, dist=dist, cutoff=cutoff, target=target))
 
 
@@ -1063,7 +1064,7 @@ def _bellman_ford(G, source, weight, pred=None, paths=None, dist=None,
     Parameters
     ----------
     G : NetworkX graph
-    
+
     source: list
         List of source nodes
 
@@ -1088,7 +1089,7 @@ def _bellman_ford(G, source, weight, pred=None, paths=None, dist=None,
 
     cutoff: integer or float, optional
         Depth to stop the search. Only paths of length <= cutoff are returned
-        
+
     target: node label, optional
         Ending node for path. Path lengths to other destinations may (and
         probably will) be incorrect.
@@ -1109,7 +1110,7 @@ def _bellman_ford(G, source, weight, pred=None, paths=None, dist=None,
 
     if pred is None:
         pred = {v: [None] for v in source}
-    
+
     if dist is None:
         dist = {v: 0 for v in source}
 
@@ -1133,11 +1134,11 @@ def _bellman_ford(G, source, weight, pred=None, paths=None, dist=None,
                 if cutoff is not None:
                     if dist_v > cutoff:
                         continue
-                                    
+
                 if target is not None:
                     if dist_v > dist.get(target, inf):
                         continue
-                    
+
                 if dist_v < dist.get(v, inf):
                     if v not in in_q:
                         q.append(v)
@@ -1149,24 +1150,24 @@ def _bellman_ford(G, source, weight, pred=None, paths=None, dist=None,
                         count[v] = count_v
                     dist[v] = dist_v
                     pred[v] = [u]
-                    
+
                 elif dist.get(v) is not None and dist_v == dist.get(v):
                     pred[v].append(u)
 
     if paths is not None:
         dsts = [target] if target is not None else pred
         for dst in dsts:
-        
+
             path = [dst]
             cur = dst
-            
+
             while pred[cur][0] is not None:
                 cur = pred[cur][0]
                 path.append(cur)
-            
+
             path.reverse()
             paths[dst] = path
-    
+
 
     return dist
 
@@ -1217,7 +1218,7 @@ def bellman_ford_path(G, source, target, weight='weight'):
     except KeyError:
         raise nx.NetworkXNoPath(
             "Node %s not reachable from %s" % (source, target))
-            
+
 def bellman_ford_path_length(G, source, target, weight='weight'):
     """Returns the shortest path length from source to target
     in a weighted graph.
@@ -1264,9 +1265,9 @@ def bellman_ford_path_length(G, source, target, weight='weight'):
         return 0
 
     weight = _weight_function(G, weight)
-    
+
     length =  _bellman_ford(G, [source], weight, target=target)
-    
+
     try:
         return length[target]
     except KeyError:
diff --git a/networkx/generators/atlas.py b/networkx/generators/atlas.py
--- a/networkx/generators/atlas.py
+++ b/networkx/generators/atlas.py
@@ -126,9 +126,9 @@ def graph_atlas(i):
 
     References
     ----------
-    .. [atlas] Ronald C. Read and Robin J. Wilson,
-               *An Atlas of Graphs*.
-               Oxford University Press, 1998.
+    .. [graph_atlas] Ronald C. Read and Robin J. Wilson,
+                     *An Atlas of Graphs*.
+                     Oxford University Press, 1998.
 
     """
     if not (0 <= i < NUM_GRAPHS):


Test patch: