import networkx


def solution_graph(G, path):
    """
    Return a NetworkX Graph representing solution in maze.
    Remove all vertices that are not in the path. Includes
    positional information from G.
    """
    H = networkx.DiGraph()
    pos = networkx.get_node_attributes(G, 'pos')
    for n in G.nodes():
        H.add_node(n, pos=pos.get(n))
    for idx in range(len(path)-1):
        H.add_edge(path[idx], path[idx+1])
    return H