def shortest_path_length(G, source=None, target=None, weight=None):
    if source is None:
        if target is None:
            # Find paths between all pairs.
            if weight is None:
                paths = nx.all_pairs_shortest_path_length(G)
            else:
                paths = nx.all_pairs_dijkstra_path_length(G, weight=weight)
        else:
            # Find paths from all nodes co-accessible to the target.
            with nx.utils.reversed(G):
                if weight is None:
                    # We need to exhaust the iterator as Graph needs
                    # to be reversed.
                    path_length = nx.single_source_shortest_path_length
                    paths = list(path_length(G, target))
                else:
                    path_length = nx.single_source_dijkstra_path_length
                    paths = path_length(G, target, weight=weight)
    else:
        if source not in G:
            raise nx.NodeNotFound("Source {} not in G".format(source));

        if target is None:
            # Find paths to all nodes accessible from the source.
            if weight is None:
                paths = nx.single_source_shortest_path_length(G, source)
            else:
                paths = nx.single_source_dijkstra_path_length(G, source,
                                                              weight=weight)
        else:
            # Find shortest source-target path.
            if weight is None:
                p = nx.bidirectional_shortest_path(G, source, target)
                paths = len(p)-1
            else:
                paths = nx.dijkstra_path_length(G, source, target, weight)
    return paths
Ensure _log_task_info produces the correct logs.
dataset/ETHPy150Open networkx/networkx/networkx/algorithms/shortest_paths/generic.py/shortest_path_length--crossover with--dataset/ETHPy150Open Workiva/furious/furious/tests/handlers/test__init__.py/TestLogTaskInfo.test_all_headers