Skip to content

SAS optimization and extension to multiple observations (code) #92

Description

@dufourc1

Based on https://github.com/mahalakshmi-sabanayagam/Clustering-Testing-Networks

def hist_apprx(graphs, n0=30):
    graphs_appr = []
    for graph in graphs:
        # degree sort
        nn = graph.shape[0]
        h = int(nn / n0)

        deg = torch.sum(graph, axis=1)
        id_sort = torch.argsort(-deg)

        graph_sorted = graph[id_sort]
        graph_sorted = graph_sorted[:, id_sort]

        # histogram approximation
        graph_apprx = torch.zeros((n0, n0), dtype=torch.float64).to(device=device)
        for i in range(n0):
            for j in range(i + 1):
                graph_apprx[i][j] = torch.sum(graph_sorted[i * h:i * h + h, j * h:j * h + h]) / (h * h)
                graph_apprx[j][i] = graph_apprx[i][j]

        graphs_appr.append(graph_apprx)

    return graphs_appr

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Multiple graphsMethod requiring multiple graphs as inputenhancementNew feature or requestestimatorestimator method

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions