import torch


def get_edge_matrix(n):
    """
    Input: integer n describing the size of the network or number of visible vertices
    Output: M, n(n-1)/2 x 3 matrix containing instructions on how to compute all 
    possible edges. 

    If U and V are xyz vectors, then M contains instruction to take U-V and V-U. 
    """
    M1 = torch.zeros((int(n*(n-1)/2), n))
    row = 0
    for dilation in range(1,n):
        i = 0
        while i + dilation < n:
            M1[row, i] = -1
            M1[row, i + dilation] = 1
            i += 1
            row += 1

    M2 = torch.zeros((int(n*(n-1)/2), n))
    row = 0
    for dilation in range(1,n):
        i = 0
        while i + dilation < n:
            M2[row, i] = 1
            M2[row, i + dilation] = -1
            i += 1
            row += 1

    return torch.vstack((M1, M2))