TSP–搜索BFS和DFS我要分享

TSP - search for BFS and DFS

matlab tsp dfs 搜索 bfs

关注次数: 352

下载次数: 1

文件大小: 4.01 kB

代码分类: 其他

开发平台: matlab

下载需要积分: 2积分

版权声明:如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

代码描述

中文说明:应用背景该项目由实施DFS和BFS算法解决TSP问题的案例。对于一个给定的起始城市,我们将尝试找到“最短”的路径到一个给定的目标,通过实施上述算法。下面的章节将描述我选择的方法,以及我所获得的结果。关键技术方法(整个项目将进行使用MATLAB。该脚本可在“源代码”目录中。>;>;以下是执行步骤,获得期望的结果:1)从文件中加载数据2)硬编码的邻接和连接输入3)计算的距离;仅由邻接矩阵定义的现有边的成本。4)生成相应的图,并将所有下面的步骤都限制在表示起点和终点之间的所有可能的路径上。2一、DFS算法5)生成列表的顺序图节点的访问DFS算法。6)基于节点ID在非加权图得到DFS路径。7)基于边缘的成本获得最小成本路径(DFS在加权图)8)找到最低成本。二。BFS算法9)产生有序的节点列表发现的BFS。10)生成的路径连接起点到目的地所产生的节点列表的列表结合前人。数据在这项工作中所使用的数据提供了内部。我将文件转换成txt文件。为了让它更容易导入MATLAB。有一次,转换后的文件上传,城市数量(节点)只要相应的坐标将存储在表命名为“坐标”。从这些坐标的边缘将成本计算。邻接信息将手动输入。


English Description:

Background: this project is a case of TSP problem solved by DFS and BFS algorithm. For a given starting city, we will try to find the "shortest" path to a given target by implementing the above algorithm. The following sections describe the methods I chose and the results I obtained. The key technology and method (the whole project will be carried out using matlab). The script can be found in the source directory. &The following steps are performed to obtain the desired results: 1) load data from the file 2) hard coded adjacency and join inputs 3) calculated distance; cost of existing edges defined only by adjacency matrix. 4) Generate the corresponding graph and limit all the following steps to all possible paths between the starting point and the end point. 2 1. DFS algorithm 5) access DFS algorithm of generating list sequence graph node. 6) The DFS path is obtained in the unweighted graph based on the node ID. 7) Based on the cost of the edge to obtain the minimum cost path (DFS in the weighted graph) 8) to find the lowest cost. Two. BFS algorithm 9) generates ordered node list to discover BFS. 10) The generated path connects the starting point to the destination and generates a list of nodes. The data used in this work is provided internally. I convert the file to a TXT file. To make it easier to import into Matlab. Once, after the transformation of the file upload, the number of cities (nodes) as long as the corresponding coordinates will be stored in the table named "coordinates". The cost will be calculated from the edges of these coordinates. Adjacency information will be entered manually.


代码预览