What type of algorithm is used for path finding with multiple paths yet one origin?












1















I have a graph with one origin and multiple destinations. I'm trying to find a way to word the problem to find the correct type of algorithm to solve. The goal is to have as few paths as possible to reach all of the points, yet the paths must follow grid points at all times (ie, right angles).



For example:



Origin:  (0, 0)
Point A: (3, 3)
Point B: (3, 0)
Point C: (1, 3)


A path from Origin -> C -> A is great because getting to point A only requires 2 extra segments because it was able to share the path from Origin -> C.



Some things I have thought through:




  • Exhausting all path options to all points and then exhaustively trying all combinations. This is obviously the brute force and slowest method. Doesn't scale well.

  • Creating a matrix of 1's from Origin to Point _, then performing matrix addition in order to find the highest traffic points. Then re-performing some type of exhaustive search, having a preference for those paths which follow the high-traffic segments.


What I would love to do is draw the "top" ways to get to each point from the origin, and then compare each path to each other path to see where they could share paths. This feels recursively tricky.



So, my question is less looking for an answer to the specific problem, and more trying to figure out how to approach the problem, ie, which path (pun intended) to go down when trying to solve.



Overall, looking to score paths based on (no particular order yet):




  • Number of segments shared vs unique segments

  • Number of turns (preferring straight lines)

  • Shortest distance










share|improve this question



























    1















    I have a graph with one origin and multiple destinations. I'm trying to find a way to word the problem to find the correct type of algorithm to solve. The goal is to have as few paths as possible to reach all of the points, yet the paths must follow grid points at all times (ie, right angles).



    For example:



    Origin:  (0, 0)
    Point A: (3, 3)
    Point B: (3, 0)
    Point C: (1, 3)


    A path from Origin -> C -> A is great because getting to point A only requires 2 extra segments because it was able to share the path from Origin -> C.



    Some things I have thought through:




    • Exhausting all path options to all points and then exhaustively trying all combinations. This is obviously the brute force and slowest method. Doesn't scale well.

    • Creating a matrix of 1's from Origin to Point _, then performing matrix addition in order to find the highest traffic points. Then re-performing some type of exhaustive search, having a preference for those paths which follow the high-traffic segments.


    What I would love to do is draw the "top" ways to get to each point from the origin, and then compare each path to each other path to see where they could share paths. This feels recursively tricky.



    So, my question is less looking for an answer to the specific problem, and more trying to figure out how to approach the problem, ie, which path (pun intended) to go down when trying to solve.



    Overall, looking to score paths based on (no particular order yet):




    • Number of segments shared vs unique segments

    • Number of turns (preferring straight lines)

    • Shortest distance










    share|improve this question

























      1












      1








      1








      I have a graph with one origin and multiple destinations. I'm trying to find a way to word the problem to find the correct type of algorithm to solve. The goal is to have as few paths as possible to reach all of the points, yet the paths must follow grid points at all times (ie, right angles).



      For example:



      Origin:  (0, 0)
      Point A: (3, 3)
      Point B: (3, 0)
      Point C: (1, 3)


      A path from Origin -> C -> A is great because getting to point A only requires 2 extra segments because it was able to share the path from Origin -> C.



      Some things I have thought through:




      • Exhausting all path options to all points and then exhaustively trying all combinations. This is obviously the brute force and slowest method. Doesn't scale well.

      • Creating a matrix of 1's from Origin to Point _, then performing matrix addition in order to find the highest traffic points. Then re-performing some type of exhaustive search, having a preference for those paths which follow the high-traffic segments.


      What I would love to do is draw the "top" ways to get to each point from the origin, and then compare each path to each other path to see where they could share paths. This feels recursively tricky.



      So, my question is less looking for an answer to the specific problem, and more trying to figure out how to approach the problem, ie, which path (pun intended) to go down when trying to solve.



      Overall, looking to score paths based on (no particular order yet):




      • Number of segments shared vs unique segments

      • Number of turns (preferring straight lines)

      • Shortest distance










      share|improve this question














      I have a graph with one origin and multiple destinations. I'm trying to find a way to word the problem to find the correct type of algorithm to solve. The goal is to have as few paths as possible to reach all of the points, yet the paths must follow grid points at all times (ie, right angles).



      For example:



      Origin:  (0, 0)
      Point A: (3, 3)
      Point B: (3, 0)
      Point C: (1, 3)


      A path from Origin -> C -> A is great because getting to point A only requires 2 extra segments because it was able to share the path from Origin -> C.



      Some things I have thought through:




      • Exhausting all path options to all points and then exhaustively trying all combinations. This is obviously the brute force and slowest method. Doesn't scale well.

      • Creating a matrix of 1's from Origin to Point _, then performing matrix addition in order to find the highest traffic points. Then re-performing some type of exhaustive search, having a preference for those paths which follow the high-traffic segments.


      What I would love to do is draw the "top" ways to get to each point from the origin, and then compare each path to each other path to see where they could share paths. This feels recursively tricky.



      So, my question is less looking for an answer to the specific problem, and more trying to figure out how to approach the problem, ie, which path (pun intended) to go down when trying to solve.



      Overall, looking to score paths based on (no particular order yet):




      • Number of segments shared vs unique segments

      • Number of turns (preferring straight lines)

      • Shortest distance







      algorithm graph-theory






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 12:01









      bentedderbentedder

      464317




      464317
























          2 Answers
          2






          active

          oldest

          votes


















          1














          This does not seem similar to minimal spanning tree, but to Steiner tree, https://en.wikipedia.org/wiki/Steiner_tree_problem in particular rectilinear Steiner tree.



          https://en.wikipedia.org/wiki/Rectilinear_Steiner_tree



          Unfortunately that is NP-hard.






          share|improve this answer
























          • Yeah, you're right, it's exactly the rectilinear steiner tree. Now, I can possibly split up my grid into smaller zones. A graph with, say, 40 vertices, could be split up into 8 zones, each zone having 5 vertices to reach using the rectilinear steiner tree from the origin point at (0,0). I wonder if that would reduce the complexity.

            – bentedder
            Nov 13 '18 at 17:07



















          1














          Since you can actually reach all points from any point on 2D-space, then you can represent it as a complete graph with N nodes and N * (N - 1) / 2 edges - from each point to all others.



          The weight of every edge can express the distance between two nodes, which is equal to the the distance between this points by x plus distance by y, because you only use right angles:




          W[a, b] = = |a.x - b.x| + |a.y - b.y|




          Now, you have a normal graph, represented by the set of nodes and edges and you can apply any desired algorithms.



          It is pretty unclear what score exactly you want to achieve, but building the minimal spanning tree sounds like the answer to the most optimal paths problem.

          For example, you can use Kruskal's algorithm to achieve it.






          share|improve this answer

























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280620%2fwhat-type-of-algorithm-is-used-for-path-finding-with-multiple-paths-yet-one-orig%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            This does not seem similar to minimal spanning tree, but to Steiner tree, https://en.wikipedia.org/wiki/Steiner_tree_problem in particular rectilinear Steiner tree.



            https://en.wikipedia.org/wiki/Rectilinear_Steiner_tree



            Unfortunately that is NP-hard.






            share|improve this answer
























            • Yeah, you're right, it's exactly the rectilinear steiner tree. Now, I can possibly split up my grid into smaller zones. A graph with, say, 40 vertices, could be split up into 8 zones, each zone having 5 vertices to reach using the rectilinear steiner tree from the origin point at (0,0). I wonder if that would reduce the complexity.

              – bentedder
              Nov 13 '18 at 17:07
















            1














            This does not seem similar to minimal spanning tree, but to Steiner tree, https://en.wikipedia.org/wiki/Steiner_tree_problem in particular rectilinear Steiner tree.



            https://en.wikipedia.org/wiki/Rectilinear_Steiner_tree



            Unfortunately that is NP-hard.






            share|improve this answer
























            • Yeah, you're right, it's exactly the rectilinear steiner tree. Now, I can possibly split up my grid into smaller zones. A graph with, say, 40 vertices, could be split up into 8 zones, each zone having 5 vertices to reach using the rectilinear steiner tree from the origin point at (0,0). I wonder if that would reduce the complexity.

              – bentedder
              Nov 13 '18 at 17:07














            1












            1








            1







            This does not seem similar to minimal spanning tree, but to Steiner tree, https://en.wikipedia.org/wiki/Steiner_tree_problem in particular rectilinear Steiner tree.



            https://en.wikipedia.org/wiki/Rectilinear_Steiner_tree



            Unfortunately that is NP-hard.






            share|improve this answer













            This does not seem similar to minimal spanning tree, but to Steiner tree, https://en.wikipedia.org/wiki/Steiner_tree_problem in particular rectilinear Steiner tree.



            https://en.wikipedia.org/wiki/Rectilinear_Steiner_tree



            Unfortunately that is NP-hard.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 13 '18 at 15:20









            Hans OlssonHans Olsson

            3,539422




            3,539422













            • Yeah, you're right, it's exactly the rectilinear steiner tree. Now, I can possibly split up my grid into smaller zones. A graph with, say, 40 vertices, could be split up into 8 zones, each zone having 5 vertices to reach using the rectilinear steiner tree from the origin point at (0,0). I wonder if that would reduce the complexity.

              – bentedder
              Nov 13 '18 at 17:07



















            • Yeah, you're right, it's exactly the rectilinear steiner tree. Now, I can possibly split up my grid into smaller zones. A graph with, say, 40 vertices, could be split up into 8 zones, each zone having 5 vertices to reach using the rectilinear steiner tree from the origin point at (0,0). I wonder if that would reduce the complexity.

              – bentedder
              Nov 13 '18 at 17:07

















            Yeah, you're right, it's exactly the rectilinear steiner tree. Now, I can possibly split up my grid into smaller zones. A graph with, say, 40 vertices, could be split up into 8 zones, each zone having 5 vertices to reach using the rectilinear steiner tree from the origin point at (0,0). I wonder if that would reduce the complexity.

            – bentedder
            Nov 13 '18 at 17:07





            Yeah, you're right, it's exactly the rectilinear steiner tree. Now, I can possibly split up my grid into smaller zones. A graph with, say, 40 vertices, could be split up into 8 zones, each zone having 5 vertices to reach using the rectilinear steiner tree from the origin point at (0,0). I wonder if that would reduce the complexity.

            – bentedder
            Nov 13 '18 at 17:07













            1














            Since you can actually reach all points from any point on 2D-space, then you can represent it as a complete graph with N nodes and N * (N - 1) / 2 edges - from each point to all others.



            The weight of every edge can express the distance between two nodes, which is equal to the the distance between this points by x plus distance by y, because you only use right angles:




            W[a, b] = = |a.x - b.x| + |a.y - b.y|




            Now, you have a normal graph, represented by the set of nodes and edges and you can apply any desired algorithms.



            It is pretty unclear what score exactly you want to achieve, but building the minimal spanning tree sounds like the answer to the most optimal paths problem.

            For example, you can use Kruskal's algorithm to achieve it.






            share|improve this answer






























              1














              Since you can actually reach all points from any point on 2D-space, then you can represent it as a complete graph with N nodes and N * (N - 1) / 2 edges - from each point to all others.



              The weight of every edge can express the distance between two nodes, which is equal to the the distance between this points by x plus distance by y, because you only use right angles:




              W[a, b] = = |a.x - b.x| + |a.y - b.y|




              Now, you have a normal graph, represented by the set of nodes and edges and you can apply any desired algorithms.



              It is pretty unclear what score exactly you want to achieve, but building the minimal spanning tree sounds like the answer to the most optimal paths problem.

              For example, you can use Kruskal's algorithm to achieve it.






              share|improve this answer




























                1












                1








                1







                Since you can actually reach all points from any point on 2D-space, then you can represent it as a complete graph with N nodes and N * (N - 1) / 2 edges - from each point to all others.



                The weight of every edge can express the distance between two nodes, which is equal to the the distance between this points by x plus distance by y, because you only use right angles:




                W[a, b] = = |a.x - b.x| + |a.y - b.y|




                Now, you have a normal graph, represented by the set of nodes and edges and you can apply any desired algorithms.



                It is pretty unclear what score exactly you want to achieve, but building the minimal spanning tree sounds like the answer to the most optimal paths problem.

                For example, you can use Kruskal's algorithm to achieve it.






                share|improve this answer















                Since you can actually reach all points from any point on 2D-space, then you can represent it as a complete graph with N nodes and N * (N - 1) / 2 edges - from each point to all others.



                The weight of every edge can express the distance between two nodes, which is equal to the the distance between this points by x plus distance by y, because you only use right angles:




                W[a, b] = = |a.x - b.x| + |a.y - b.y|




                Now, you have a normal graph, represented by the set of nodes and edges and you can apply any desired algorithms.



                It is pretty unclear what score exactly you want to achieve, but building the minimal spanning tree sounds like the answer to the most optimal paths problem.

                For example, you can use Kruskal's algorithm to achieve it.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 13 '18 at 12:43

























                answered Nov 13 '18 at 12:38









                Yeldar KurmangaliyevYeldar Kurmangaliyev

                24.6k93866




                24.6k93866






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53280620%2fwhat-type-of-algorithm-is-used-for-path-finding-with-multiple-paths-yet-one-orig%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown