human
Solve the following python programming problem given the following code:
@not_implemented_for('multigraph')
def shortest_simple_paths(G, source, target, weight=None):
assistant
#Here is the Python program you requested.

    """Generate all simple paths in the graph G from source to target,
    starting from shortest ones.
    A simple path is a path with no repeated nodes.
    If a weighted shortest path search is to be used, no negative weights
    are allawed.
    Parameters
    G : NetworkX graph
    source : node
    Starting node for path
    target : node
    Ending node for path
    weight : string
    Name of the edge attribute to be used as a weight. If None all
    edges are considered to have unit weight. Default value None.
    Returns
    path_generator: generator
    A generator that produces lists of simple paths, in order from
    shortest to longest.
    Raises
    NetworkXNoPath
    If no path exists between source and target.
    NetworkXError
    If source or target nodes are not in the input graph.
    NetworkXNotImplemented
    If the input graph is a Multi[Di]Graph.
    Examples
    >>> G = nx.cycle_graph(7)
    >>> paths = list(nx.shortest_simple_paths(G, 0, 3))
    >>> print(paths)
    [[0, 1, 2, 3], [0, 6, 5, 4, 3]]
    You can use this function to efficiently compute the k shortest/best
    paths between two nodes.
    >>> from itertools import islice
    >>> def k_shortest_paths(G, source, target, k, weight=None):
    ...     return list(islice(nx.shortest_simple_paths(G, source, target, weight=weight), k))
    >>> for path in k_shortest_paths(G, 0, 3, 2):
    ...     print(path)
    [0, 1, 2, 3]
    [0, 6, 5, 4, 3]
    Notes
    This procedure is based on algorithm by Jin Y. Yen [1]_.  Finding
    the first K paths requires O(KN^3) operations.
    See Also
    all_shortest_paths
    shortest_path
    all_simple_paths
    References
    .. [1] Jin Y. Yen, "Finding the K Shortest Loopless Paths in a
    Network", Management Science, Vol. 17, No. 11, Theory Series
    (Jul., 1971), pp. 712-716.
    """
    if (source not in G):
        raise nx.NodeNotFound(('source    node    %s    not    in    graph' % source))
    if (target not in G):
        raise nx.NodeNotFound(('target    node    %s    not    in    graph' % target))
    if (weight is None):
        length_func = len
        shortest_path_func = _bidirectional_shortest_path
    else:
        def length_func(path):
            return sum((G.adj[u][v][weight] for (u, v) in zip(path, path[1:])))
        shortest_path_func = _bidirectional_dijkstra
    listA = list()
    listB = PathBuffer()
    prev_path = None
    while True:
        if (not prev_path):
            (length, path) = shortest_path_func(G, source, target, weight=weight)
            listB.push(length, path)
        else:
            ignore_nodes = set()
            ignore_edges = set()
            for i in range(1, len(prev_path)):
                root = prev_path[:i]
                root_length = length_func(root)
                for path in listA:
                    if (path[:i] == root):
                        ignore_edges.add((path[(i - 1)], path[i]))
                ignore_nodes.add(root[(-1)])
                try:
                    (length, spur) = shortest_path_func(G, root[(-1)], target, ignore_nodes=ignore_nodes, ignore_edges=ignore_edges, weight=weight)
                    path = (root[:(-1)] + spur)
                    listB.push((root_length + length), path)
                except nx.NetworkXNoPath:
                    pass
        if listB:
            path = listB.pop()
            (yield path)
            listA.append(path)
            prev_path = path
        else:
            break