How to apply Pathfinding in a structure of nodes?

Asked

Viewed 67 times

6

I have a node structure that represents my pages and their links, for example, from page A I can go to page B or page C. In addition I can have page A pointing to page B pointing to C pointing again to A. What I need to do is determine a source page and a destination page, and display only the related nodes, for example leaving A, to reach H.

inserir a descrição da imagem aqui

Which algorithm is used to find this type of path?

1 answer

3

There are several algorithms for this purpose, among them (all in English):

Dijkstra’s

Here’s an example of pseudo-code taken from the link:

function Dijkstra(Graph, source):

       create vertex set Q

       for each vertex v in Graph:             
           dist[v] ← INFINITY
           prev[v] ← UNDEFINED
           add v to Q

      dist[source] ← 0

      while Q is not empty:
          u ← vertex in Q with min dist[u]
          remove u from Q 

          for each neighbor v of u:           
              alt ← dist[u] + length(u, v)
              if alt < dist[v]:
                  dist[v] ← alt 
                  prev[v] ← u 

      return dist[], prev[]

D* Algorithm D-Star

Algorithmic Any-Angle path Planning

To* Algorithm A-Star

  • 1

    For me a link would already forward the answer, but there is an interesting discussion about it in the community: http://meta.pt.stackoverflow.com/questions/42/queremos-resposes-que-contenham-somente-links

  • 2

    @Pagotti the question is as straightforward as the answer : "What algorithm is used to find this type of path?" , and yet thought of it I was careful to transfer the link algorithm to my response. In addition, even if the links break the answer will be correct, because these techniques are as standards and will always be present for consultation.

  • quiet, as I said, for me it would be enough. I commented for being a concern of the OS and also having had a discussion about it here at Sopt.

  • 1

    What could I answer ? If I put only the names, without the links, tmb would be correct in my view... This kind of concern is given when the answer itself is on the link, which is not the case... But I understand your remark, I just think because it’s an objective question, the answer might also be...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.