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

hypergraphx.dynamics.transition_matrix not working when edges are not ordered from 0 to N #28

Open
larryzhang95 opened this issue Feb 2, 2024 · 3 comments

Comments

@larryzhang95
Copy link

I was trying to use the random walk function which depends on the transition_matrix matrix function in the dynamics submodule.

I got the error:

IndexError: index 492 is out of bounds for axis 0 with size 92

when I ran adjacency_matrix(H) where H is the hypergraph from 'test_data/workplace

I then dug further and noticed that in the hedge_list list in transition_matrix, the first edge printed out is (492, 938).

For the code in transition_matrix:

    for l in hedge_list:
        for i in range(len(l)):
            for j in range(i+1, len(l)):
                T[l[i], l[j]] += len(l) - 1
                T[l[j], l[i]] += len(l) - 1

T[l[i],l[j]] , would index T[492, 938]. T is only size 92 x 92, and thus this would be invalid.

My guess is that an easy fix for this is to find the index of the value l[i] and l[j] would solve this. I will try it on my end and report back

@larryzhang95
Copy link
Author

    for l in hedge_list:
        for i in range(len(l)):
            for j in range(i+1, len(l)):
                T[nodes.index(l[i]), nodes.index(l[j])] += len(l) - 1
                T[nodes.index(l[j]), nodes.index(l[i])] += len(l) - 1

Changing to this did work, though I would test it further just in case

@larryzhang95
Copy link
Author

I also added a nodes variable :

nodes = HG.get_nodes()

@FraLotito
Copy link
Contributor

Thanks for reporting this! Yes, it seems that we are missing a mapping from nodes to integers ids in [0, N) in that functions, I'll fix that soon.

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

No branches or pull requests

2 participants