First time here? Check out the FAQ!

Ask Your Question
0

all_simple_paths generates AttributeError for graphs

asked 1 year ago

weux082690 gravatar image

Minimum working example (which causes error on CoCalc, but also on my own machine):

G = graphs.CompleteGraph(5)
G.all_paths(1,3)
G.all_simple_paths()

This gives an error saying that "all_simple_paths" is not an attribute for the "Graph" object, even though the function is present in the sage.graphs.path_enumeration module, where all_paths is from the line above, which works just fine. I have checked other functions in the module and found that other than all_paths, shortest_simple_paths seems to be the only other one in this module which works. The rest also give attribute errors.

I am wanting to use the all_simple_paths function due to its ability to have accept a list of starting and ending vertices, instead of just one start and end like the all_paths function. However, it refuses to work. Trying to import the module manually does not seem to effect anything. Does anyone know why this function does not work?

Preview: (hide)

Comments

2 Answers

Sort by » oldest newest most voted
0

answered 1 year ago

all_simple_paths is defined for directed graphs (instances of DiGraph in Sage) but not for general graphs. This should work:

G = digraphs.Complete(5)  # not graphs.CompeteGraph(5)
G.all_paths(1,3)
G.all_simple_paths()
Preview: (hide)
link

Comments

The fact that all_simple_pathis not implemented for undirected graphs is not documented. It should. (Or this method should be implemented for undirected graph, if the thing is possible...).

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 1 year ago )
1

answered 1 year ago

updated 1 year ago

Thanks for reporting this issue.

With https://github.com/sagemath/sage/pull..., we extend the method to work on both Graph and DiGraph.

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 1 year ago

Seen: 285 times

Last updated: Feb 08 '24