def determine_positions(nodes, edges):
    """
    Construct the problem instance to solve the positions of contigs.

    The input for spring_system() is A, K, L, which looks like the following.
    A = np.array([[1, -1, 0], [0, 1, -1], [1, 0, -1]])
    K = np.eye(3, dtype=int)
    L = np.array([1, 2, 3])

    For example, A-B distance 1, B-C distance 2, A-C distance 3, solve positions

    >>> determine_positions([0, 1, 2], [(0, 1, 1), (1, 2, 2), (0, 2, 3)])
    array([0, 1, 3])
    """
    N = len(nodes)
    E = len(edges)

    A = np.zeros((E, N), dtype=int)
    for i, (a, b, distance) in enumerate(edges):
        A[i, a] = 1
        A[i, b] = -1

    K = np.eye(E, dtype=int)
    L = np.array([x[-1] for x in edges])

    s = spring_system(A, K, L)
    return np.array([0] + [int(round(x, 0)) for x in s])
Construct the problem instance to solve the positions of contigs.

    The input for spring_system() is A, K, L, which looks like the following.
    A = np.array([[1, -1, 0], [0, 1, -1], [1, 0, -1]])
    K = np.eye(3, dtype=int)
    L = np.array([1, 2, 3])

    For example, A-B distance 1, B-C distance 2, A-C distance 3, solve positions

    >>> determine_positions([0, 1, 2], [(0, 1, 1), (1, 2, 2), (0, 2, 3)])
    array([0, 1, 3])