-
Notifications
You must be signed in to change notification settings - Fork 9
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
Leiden not working for Zacharys Karate Club dataset #43
Comments
@nicarq I just now have looked at this - I'm sorry for not seeing it sooner! After MSFT stopped actively committing to graspologic-org, I didn't get any notifications about this until just now. I'll take a look at this soon and get back to you, if only so we both know what went wrong, even if it isn't something you're actively looking into any longer |
Rather than go through the way your code did, I really quickly slammed this together in python (but we can make some educated assessments from there): Rough code, syntax not guaranteed to be accurate: mkdir quicktest
cd quicktest
uv init
uv add graspologic # I'm too tired to look up the actual version of networkx, so I made graspologic pull it for me.
uv add ipython
uv run ipython import graspologic_native as gpn
import networkx as nx
karate = nx.karate_club_graph()
edges = [(str(source), str(target), data["weight"]) for source, target, data in karate.edges(data=True)]
gpn.leiden(edges) Returned:
so, we know it's clustering - the modularity is kinda poor and there's only 4 clusters, but that's still more right than the that you were getting in your example. nobody wants something that useless, so we need to figure out what's up. My theory is the karate club edge list you are loading is possibly a: repeating edges and effectively overwriting their weights, or b: not summing weights when it should have (it's kinda unclear which it is) The edges that networkx packages up for karate club are, in (source, target, weight) tuple3's:
Looking at your gml / csv file, it does not have any weights, and it also doesn't have a multigraph that can be described as a weighted undirected graph, and that will be problematic. It looks like your graph in the gml is behaving as a directed graph without weights, and ... while I can't say it's wrong in it's response, I do know that leiden is not really intended to be done on any graph that isn't an Undirected, Weighted, Non-Multigraph (meaning there is precisely one edge from a to b, so if you do in fact have a multigraph, you can sum the weights (or count the edges) and collapse it into a single Again, my apologies for looking at this so late. I'll make sure I put a watch on this repo so I don't miss anything further. Cheers! |
I tried using Leiden for the classic dataset of Zacharys Karate Club but it's not working. I wonder what I'm doing wrong. It didn't cluster anything at all.
This is what I get
the code is here https://github.com/nicarq/example-leiden-rust/tree/main fwiw I may had done something incorrect when using the library because it's strange that it didn't work
The text was updated successfully, but these errors were encountered: