code: def test_shortest_path_target(self):
      answer = {0: [0, 1], 1: [1], 2: [2, 1]}
      sp = nx.shortest_path(nx.path_graph(3), target=1)
      assert sp == answer
      # with weights
      sp = nx.shortest_path(nx.path_graph(3), target=1, weight="weight")
      assert sp == answer
      # weights and method specified
      sp = nx.shortest_path(
          nx.path_graph(3), target=1, weight="weight", method="dijkstra"
      )
      assert sp == answer
      sp = nx.shortest_path(
          nx.path_graph(3),
          target=1,
          weight="weight",
          method="bellman-ford",
      )
      assert sp == answer
  
imports: import pytest
  import networkx
label_desc: Use image node_id 3 for calling the TestGenericPath obj's underlying member method code with example usage: obj.test_shortest_path_target() without return types