Answer the question
In order to leave comments, you need to log in
How to search for the shortest path on a graph using an array of data?
There is an undirected graph:
Is it possible (no matter what method) to find the shortest paths x1 -> x5 on a graph using an array of data? Where x1..x2 are values from the table:
And in the response, get the table of paths:
Answer the question
In order to leave comments, you need to log in
Damn, people, have you already forgotten how to use Google or are you just too lazy *?
The first link gives the richest food for the brain:
https://habr.com/ru/post/119158/
And if you strain your brain a little and read what is written in the following three or four links, then you can already be cool specialist.
If you need to " just load an array and get an answer ", then there are quite a few such possibilities, for example, here is one of them:
https://github.com/pmatiello/python-graph
In general, the algorithm for finding the shortest path in a graph is studied in any specialty at least slightly related to IT.
Judging by the drawn graph, there are two options for the path:
1. x1-x2-x5
2. x1-x3-x4-x5
Of these two, you need to choose the smaller one.
The edge x2-x3 must be excluded, because in a triangle x1-x2-x3 it is always more profitable to choose one of the sides x1-x3 or
x1-x2 than two sides (x1-x2 + x2-x3 or x1-x3 + x3-x2).
Knowing this, a simple addition on your table is easy to find the answer.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question