class_docstr: Unit tests for the :func:`networkx.dijkstra_path_length`
  function.
class_docstr_tok: ["Unit","tests","for","the",":","func",":","`","networkx.dijkstra_path_length","`","function","."]
docstr: Tests for computing the length of the shortest path using
  Dijkstra's algorithm with a user-defined weight function.
code: def test_weight_function(self):
      """Tests for computing the length of the shortest path using
      Dijkstra's algorithm with a user-defined weight function.
  
      """
      # Create a triangle in which the edge from node 0 to node 2 has
      # a large weight and the other two edges have a small weight.
      G = nx.complete_graph(3)
      G.adj[0][2]["weight"] = 10
      G.adj[0][1]["weight"] = 1
      G.adj[1][2]["weight"] = 1
  
      # The weight function will take the multiplicative inverse of
      # the weights on the edges. This way, weights that were large
      # before now become small and vice versa.
  
      def weight(u, v, d):
          return 1 / d["weight"]
  
      # The shortest path from 0 to 2 using the actual weights on the
      # edges should be [0, 1, 2]. However, with the above weight
      # function, the shortest path should be [0, 2], since that has a
      # very small weight.
      length = nx.dijkstra_path_length(G, 0, 2, weight=weight)
      assert length == 1 / 10
  
imports: import pytest
  import networkx
  from networkx.utils import pairwise
label_desc: Use image node_id 1 for calling the TestDijkstraPathLength obj's underlying member method code with example usage: obj.test_weight_function() and returns: unknown