Open bdpedigo opened 1 month ago
hey @bdpedigo! that's a great point, we should definitely fail early on these.
The obvious reason we don't support multi-component motifs is that there is an exponential cost to enumerating motif matches for each connected component; what would be the sort of behavior you prefer? docs that make this explicit? a check at call-time that raises an exception? it doesn't raise right now because I've been trying to minimize the number of branches in the find_motifs
call. but of course, uninterpretable errors = bad :)
PS: excited that grandiso is useful to you :)
I guess a third option is computing matches for each component and returning them either as a product map (A1+B1
, A1+B2
, ... An+Bn
) or as a list of length n
with match lists for each...
PS: excited that grandiso is useful to you :)
Same! 🎉
I feel the simplest answer would be to just throw an error if the input motif is not fully connected. And given that this would be dictating the allowed inputs, a brief line in the documentation that says "input motif must be one connected component" also seems warranted.
In terms of behavior if you were to allow this kind of thing, I would default to whatever networkx is doing currently (since it does at least run):
nx_motifs = list(
nx.isomorphism.DiGraphMatcher(host, motif).subgraph_monomorphisms_iter()
)
I suspect it in practice it is something like your product map (if I understand you correctly) but I doubt they are doing anything explicit to recognize that this subgraph is disconnected when they compute it. That being said, I have what I need for my application, so no pressure at all here to change the implementation.
I like that solution — will add shortly :)
Encountered an error when feeding in some motifs that had isolated nodes.
Code:
Error:
Totally understand if you want to punt on how whether/how to execute the search with these disconnected motifs, but some documentation and/or early value erroring around this would be helpful. Took me a while to figure out what I was doing wrong (since the NetworkX will execute for these cases).