Find all paths between two points

Source: Internet
Author: User

 

When performing route computing, we need to solve the problem of finding all the paths between two points ., For example, all paths between 0 and 11 are required. The adjacent relationship is already in the file named "nodetable1.txt ". Similar to a route neighbor table between all nodes and 11. In this table, only one number in a row indicates the vertex number (to subtract 100, for example, 102 corresponds to node 2 ). There are two numbers indicating the route adjacent items under this node (the first number indicates the destination point to go, and the second number indicates the next node to go to this destination. For details, see the following description)

102 (minus 100, indicating Node 2)

11 5 (the target node is node 11 and the next node to go to the target node is node 5)

11 6 (the target node is node 11 and the next node to go to the target node is node 6)

Obviously, this is an adjacent relationship in the figure.

 

Note: All Tables whose Calculation targets are node 11 (this is because all table items in node nodetable1.txt are directed to node 11 ). To run the program, you must enter the start point. For example, if you enter 0, all the paths from node 0 to node 11 are calculated. The running result is as follows:

++

The first path is: 0 --> 1 --> 4 --> 11

The first path is: 0 --> 1 --> 3 --> 11

The first path is: 0 --> 1 --> 2 --> 6 --> 10 --> 11

The first path is: 0 --> 1 --> 2 --> 6 --> 9 --> 11

The first path is: 0 --> 1 --> 2 --> 5 --> 8 --> 11

The first path is: 0 --> 1 --> 2 --> 5 --> 7 --> 11

++

 

......

 

And so on.

For details about the program, see:Http://download.csdn.net/source/2499950 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.