Ask Your Question
0

all_simple_paths generates AttributeError for graphs

asked 2024-01-31 01:16:27 +0200

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?

edit retag flag offensive close merge delete

Comments

2 Answers

Sort by ยป oldest newest most voted
0

answered 2024-01-31 01:44:48 +0200

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()
edit flag offensive delete link more

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 ( 2024-01-31 05:55:43 +0200 )edit
1

answered 2024-02-08 19:38:58 +0200

updated 2024-02-08 19:39:45 +0200

Thanks for reporting this issue.

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

edit flag offensive delete link more

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: 2024-01-31 01:16:27 +0200

Seen: 126 times

Last updated: Feb 08