def prune_graph(g):
    """ Remove unconnected nodes """
    nodes2remove = []
    for n in g.nodes():
        if len(g[n]) == 0:
            nodes2remove.append(n)
    for n in nodes2remove:
        g.remove_node(n)
