Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong dim of linalg degree when no neighbours #74

Closed
maximelucas opened this issue Apr 11, 2022 · 0 comments · Fixed by #75
Closed

Wrong dim of linalg degree when no neighbours #74

maximelucas opened this issue Apr 11, 2022 · 0 comments · Fixed by #75

Comments

@maximelucas
Copy link
Collaborator

Running

import xgi

edges = [[0,1], [0,2], [1,2,3]]
H = xgi.Hypergraph(edges)

yields

xgi.degree(H, order=3).shape
## --> (0,)

but it should be (4,), the number of nodes.

This then yields an error when running xgi.laplacian(H, order=3), because it conflicts with the (correct) dimension of the adjacency matrix:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [16], in <cell line: 1>()
----> 1 xgi.laplacian(H, order=3).shape

File ~/Dropbox (ISI Foundation)/WORK/SCIENCE/xgi/xgi/linalg/matrix.py:274, in laplacian(H, order, rescale_per_node, index)
    270     return (np.array([]), {}) if index else np.array([])
    272 K = degree(H, order=order, index=False)
--> 274 L = order * np.diag(np.ravel(K)) - A  # ravel needed to convert sparse matrix
    275 L = np.asarray(L)
    277 if rescale_per_node:

ValueError: operands could not be broadcast together with shapes (0,0) (4,4)
leotrs pushed a commit that referenced this issue Apr 11, 2022
fix: #74 wrong dimension for degree when no neighbours
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant