shortest-path

Why is the list_comprehension version slower (python)? Are there better ways?

Why is the list_comprehension version slower (python)? Are there better ways? Question: I have a line of code, and I’m surprised, that the list comprehended version is slower. I want to calculate "average sphere distances". The steps needed to be done: choose a node chose all elements at a distance "d" around it (shell at …

Total answers: 1

Find shortest path on graph with 1 character difference

Find shortest path on graph with 1 character difference Question: I have a somewhat complicated question. I am provided a list of words (each word has the same length). I am given two words into my function (StartNode and EndNode) and my task is to find the shortest path between the two (A follow-up would …

Total answers: 1

Find all shortest paths between all pairs of nodes in NetworkX

Find all shortest paths between all pairs of nodes in NetworkX Question: I am trying to get all shortest paths between all pairs of nodes in an undirected unweighted graph. I am currently using nx.all_pairs_shortest_path(), but I don’t understand why it only returns one shortest path for every pair of nodes. There are cycles in …

Total answers: 4

Shortest path in a grid using BFS

Shortest path in a grid using BFS Question: The grid consists of following items as python list of lists g = [ [‘1’, ‘1’, ‘1’, ‘1’, ‘1’], [‘S’, ‘1’, ‘X’, ‘1’, ‘1’], [‘1’, ‘1’, ‘1’, ‘1’, ‘1’], [‘X’, ‘1’, ‘1’, ‘E’, ‘1’], [‘1’, ‘1’, ‘1’, ‘1’, ‘X’] ] S indicates the start, E indicates the …

Total answers: 2

How do I get the vertices on the shortest path using igraph?

How do I get the vertices on the shortest path using igraph? Question: I’m using igraph to generate a matrix of shortest path distances between pairs of vertices but I can’t figure out how to return the vertices. So far I have: path_length_matrix = ig_graph.shortest_paths_dijkstra(None,None,”distance”, “ALL”) I’m looking for a function which returns a matrix …

Total answers: 3