Skip to content

Commit

Permalink
Fixed unnecessary assignments and main code in latentclique_lifting.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriciogtec committed Jul 13, 2024
1 parent 8339b07 commit 0f52706
Showing 1 changed file with 20 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -799,32 +799,30 @@ def _sample_from_ibp(K, alpha, sigma, c):

data = np.ones(len(rowidx), int)
shape = (K, Ncols)
Z = csr_matrix((data, (rowidx, colidx)), shape)
return csr_matrix((data, (rowidx, colidx)), shape)

return Z

# if __name__ == "__main__":
# K, alpha, sigma, c, pie = 30, 3, 0.7, 5, 1.0
# Z = _sample_from_ibp(K, alpha, sigma, c)

if __name__ == "__main__":
K, alpha, sigma, c, pie = 30, 3, 0.7, 5, 1.0
Z = _sample_from_ibp(K, alpha, sigma, c)
# cic = (Z.transpose() @ Z).toarray()
# adj = np.minimum(cic - np.diag(np.diag(cic)), 1)

cic = (Z.transpose() @ Z).toarray()
adj = np.minimum(cic - np.diag(np.diag(cic)), 1)
# # delete edges with prob 1 - exp(pi^)
# prob = np.exp(-((1 - pie) ** 2))
# triu_mask = np.triu(np.ones_like(adj), 1)
# adj = np.random.binomial(1, prob, adj.shape) * adj * triu_mask
# adj = adj + adj.T

# delete edges with prob 1 - exp(pi^)
prob = np.exp(-((1 - pie) ** 2))
triu_mask = np.triu(np.ones_like(adj), 1)
adj = np.random.binomial(1, prob, adj.shape) * adj * triu_mask
adj = adj + adj.T
# g = nx.from_numpy_matrix(adj)
# print("Number of edges:", g.number_of_edges())
# print("Number of nodes:", g.number_of_nodes())

g = nx.from_numpy_matrix(adj)
print("Number of edges:", g.number_of_edges())
print("Number of nodes:", g.number_of_nodes())
# # Transform to a torch geometric data object
# data = torch_geometric.utils.from_networkx(g)
# data.x = torch.ones(data.num_nodes, 1)

# Transform to a torch geometric data object
data = torch_geometric.utils.from_networkx(g)
data.x = torch.ones(data.num_nodes, 1)

# Lift the topology to a cell complex
lifting = LatentCliqueLifting(edge_prob_mean=0.99)
complex = lifting.lift_topology(data, verbose=True)
# # Lift the topology to a cell complex
# lifting = LatentCliqueLifting(edge_prob_mean=0.99)
# complex = lifting.lift_topology(data, verbose=True)

0 comments on commit 0f52706

Please sign in to comment.