x, y = np.array([1, 4, 2, 3, 9]), np.array([2, 5, 7, 9, 2])
edges = np.array([[0, 1], [3, 4], [3, 2], [2, 4], [2, 1]])
ys = np.vstack((y[edges[:, (0)]], y[edges[:, (1)]], y[edges[:, (0)]] + np.nan)
    ).T.flatten()
xs = np.vstack((x[edges[:, (0)]], x[edges[:, (1)]], x[edges[:, (0)]] + np.nan)
    ).T.flatten()
lines2d = plt.plot(xs, ys, marker='o')
Анимировать граф точек, соединенных ребрами