Hi,
Given an undirected graph G, and two vertices u and v of G, I want to list 
all paths from u to v with a length of d_G(u,v).  The built-in function 
shortest_simple_paths 
<https://doc.sagemath.org/html/en/reference/graphs/sage/graphs/generic_graph.html#sage.graphs.generic_graph.GenericGraph.shortest_simple_paths>,
 
despite its name, seems to list *all* simple paths from u to v.  One option 
is to filter the output of shortest_simple_paths by length, e.g.
list(filter(lambda x: len(x)== 
1+G.distance(u,v)),G.shortest_simple_paths(u,v)))

However, this is extremely inefficient, since it tells sage to generate all 
simple paths and then discards most of them.  Is there a better way to get 
this information?

Thanks,
Beth

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/868b9dc9-7484-4c2f-83c1-de9d2b77bb62n%40googlegroups.com.

Reply via email to