import logging


def label_correcting(graph, start, target, Queue=None):
    """
    Find the shortest path in graph from start to target.

    Parameters
    ----------
    graph : object
    start : object
        Node in the graph.
    target : object
        Node in the graph.
    Queue : class
        Datastructure which supports "append", "pop" and "in".

    Returns
    -------
    list or None
        List of nodes, starting with start and ending with target or None if
        no path from start to target exists.
    """
    if Queue is None:
        Queue = list

    # Initialize distances
    for node in graph.nodes:
        node.dist = float("inf")
    start.dist = 0
    u = float("inf")
    q = Queue()
    q.append(start)

    # Traverse the graph
    while len(q) > 0:
        x = q.pop()
        logging.info("Traverse '%s'...", x)
        for y in graph.children(x):
            if x.dist + graph.dist(x, y) < min(y.dist, u):
                y.dist = x.dist + graph.dist(x, y)
                y.parent = x
                if y != target and y not in q:
                    q.append(y)
                if y == target:
                    u = x.dist + graph.dist(x, y)

    # Reconstruct the shortest path
    shortest_path = None
    if target.parent is not None:
        shortest_path = []
        current_node = target
        while current_node != start:
            shortest_path.append(current_node.identifier)
            current_node = current_node.parent
        shortest_path.append(start.identifier)
        shortest_path = shortest_path[::-1]
    return shortest_path