-
Notifications
You must be signed in to change notification settings - Fork 128
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
[BUG] Layouts fail for directed graphs #655
Comments
should discuss to what extent this should support directed graphs |
@bryantower - we should talk about this. I would imagine we should be able to make layouts work for a directed graph, but maybe I'm missing something. I know we had concerns over node2vec with directed but I'm still not convinced we actually have a problem. Of the phases of auto layouts, we have:
This specific ticket is primarily talking about how we don't have support for the right way to get a directed LCC (we're calling the undirected LCC from networkx every time regardless of type). But thinking more broadly - should we be able to conceivably do a directed layout? I would think yes, but I know you were talking about it before and I don't remember what exactly you told me about it. |
I think the only place where undirected is really required is the Leiden portion. We should definitely be able to support a layout for directed graphs. We use the Leiden partitioning to generate the colors. In the path specified in this bug, we should find the weakly connected component if the graph is directed and then do the appropriate transformation to make Leiden work. |
if leiden is used for auto-layouts coloring I do see how that could be an issue, but dont know that it should be a breaking one - i could imagine a world where embeddings happen on the directed graph but leiden on the undirected version of that graph, cause modularity makes sense in undirected land |
Seems like we're on the same page! |
Exactly, we just need to be able to call the right LCC function based on type. As long as we're confident the rest makes sense we should be able to make this happen easily enough. |
@dwaynepryce I agree. |
these both are probably relevant - but i was also in the middle of having someone work on #112 - the idea being that scipy's LCC check is much faster than networkx. for an embedding (say a sparse matrix is being passed to ASE) i think making that switch makes more sense. but for your use case it is probably easier to stay in networkx. perhaps we should talk about what those functions should do? |
Would be interesting to see if the time-to-convert an nx graph into a csr matrix and run that lcc check is faster than doing it all in networkx. I'll keep you guys posted after I crunch some numbers :) |
thought about that also - i bet for a big graph it might be worth it |
FYI @kareef928 has been working on the conversion stuff so we'll keep him in the loop too! |
Expected Behavior
Layouts should work with directed graphs (IMO)
Perhaps not a bug in the sense that I'm not sure we promise this works for directed, but still. If we decided to only support undirected maybe a clearer error is warranted.
Actual Behavior
NetworkXNotImplemented: not implemented for directed type
Example Code
Full Traceback
Your Environment
Additional Details
Just from these 2 lines on the traceback, I suspect this just needs to be adapted to check for weakly connected components. Or, use
graspologic.utils.is_fully_connected
from our own codebase. However in #112 we are talking about replacing the networkx-based check with a faster one from scipy. Not sure if the layouts code will always assume networkx input going forward. AFAIK there is nothing that inherently needs to be undirected for the layouts process, or am I missing something?The text was updated successfully, but these errors were encountered: