def prune_incidence_automaton(g: IncidenceAutomaton):
    '\n    Prunes the vertices of an IncidenceAutomaton that cannot be reached\n    from the intial state, or that cannot reach a final state.\n    Args:\n        g: IncidenceAutomaton, an instance of IncidenceAutomaton\n    '
    to_keep = find_reachable_vertices(g, {initial(g)})
    reverse_graph(g)
    to_keep &= find_reachable_vertices(g, finals(g))
    reverse_graph(g)
    to_remove = (set(vertices(g)) - to_keep)
    for q in to_remove:
        remove_vertex(q, g)
Prunes the vertices of an IncidenceAutomaton that cannot be reached
from the intial state, or that cannot reach a final state.
Args:
    g: IncidenceAutomaton, an instance of IncidenceAutomaton
def prune_incidence_automaton(g: IncidenceAutomaton):
    '\n    Prunes the vertices of an IncidenceAutomaton that cannot be reached\n    from the intial state, or that cannot reach a final state.\n    Args:\n        g: IncidenceAutomaton, an instance of IncidenceAutomaton\n    '
    to_keep = find_reachable_vertices(g, {initial(g)})
    reverse_graph(g)
    to_keep &= find_reachable_vertices(g, finals(g))
    reverse_graph(g)
    to_remove = (set(vertices(g)) - to_keep)
    for q in to_remove:
        remove_vertex(q, g)