def rk_dependency_graph(rkm):
    """Construct the dependency graph of the stages of a Runge-Kutta method."""
    import networkx as nx
    import numpy as np
    s = len(rkm)
    K = np.zeros((s + 1, s + 1))
    K[:, :-1] = np.vstack((rkm.A, rkm.b))
    G = nx.from_numpy_matrix(np.abs(K.T) > 0, nx.DiGraph())
    return G
