• 大小: 124KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-11
  • 语言: C#
  • 标签:

资源简介

C#最短路径算法源码

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BLL
{
    public class ShortestPathEngine
    {
        private static ShortestPathEngine _instance;
        /// 
        /// 获取最短路径解析引擎实例
        /// 

        /// 
        public static ShortestPathEngine GetInstance()
        {
            if (_instance == null)
            {
                _instance = new ShortestPathEngine();
            }
            return _instance;
        }

        #region (共有方法)
        /// 
        /// 获取开始节点到其它节点的最短路径集合
        /// 

        /// 开始节点
        /// 目的节点
        /// 地址表
        /// 提示消息
        /// 最短路径集合
        public List GetShortestPath(string fromPoint string toPoint DataTable dt out string msg)
        {
            msg = string.Empty;
            try
            {
                List pointNameU = new List();//剩余顶点
                List pointNameS = new List();//已求出最短路径的顶点的集合
                List shortPathList = new List();//最短路径对象集合
                List lastShortPathList = new List();//上一个最短路径对象集合
                List notRemovePathList = new List();//未被移除的路径对象集合

                pointNameU = GetAllPointName(dt);
                bool isCheck = CheckPoint(pointNameU fromPoint toPoint out msg);
                if (!isCheck)
                {
                    return null;
                }
                //---start 计算第一个最短路径 
                string nextPoint = fromPoint;//下个最短节点
                string startPoint = fromPoint;//开始节点
                int distance = GetDistance(fromPoint nextPoint dt);
                string path = string.Format(“{0}{1}“ fromPoint nextPoint);
                pointNameS.Add(fromPoint);//添加已为最短路径的节点
                pointNameU.Remove(fromPoint);//从剩余节点移除
                new ShortPathList(shortPathList).AddShortPath(startPoint nextPoint path distance);//添加到最短路径集合
                //---end

                List centerPointList = new List();//中间节点
                centerPointList.Add(nextPoint);

                ResolveCenterPointShortPaths(centerPointList dt pointNameU pointNameS
                    notRemovePathList shortPathList lastShortPathList startPoint);
                if (shortPathList == null || shortPathList.Count == 0)
                {
                    msg = string.Format(“不存在{0}节点到其它节点的最短路径“ fromPoint);
                    return null;
                }
                else
                {
                    return shortPathList;
                }
            }
            catch
            

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      22016  2016-06-19 14:36  ShortestPathEngine\ShortestPath\BLL\bin\Debug\BLL.dll

     文件      56832  2016-06-19 14:36  ShortestPathEngine\ShortestPath\BLL\bin\Debug\BLL.pdb

     文件       2457  2016-06-19 14:17  ShortestPathEngine\ShortestPath\BLL\BLL.csproj

     文件        252  2016-06-19 14:17  ShortestPathEngine\ShortestPath\BLL\obj\Debug\BLL.csproj.FileListAbsolute.txt

     文件      22016  2016-06-19 14:36  ShortestPathEngine\ShortestPath\BLL\obj\Debug\BLL.dll

     文件      56832  2016-06-19 14:36  ShortestPathEngine\ShortestPath\BLL\obj\Debug\BLL.pdb

     文件       6511  2016-06-19 14:16  ShortestPathEngine\ShortestPath\BLL\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件          0  2016-06-18 23:34  ShortestPathEngine\ShortestPath\BLL\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2016-06-18 23:34  ShortestPathEngine\ShortestPath\BLL\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2016-06-18 23:34  ShortestPathEngine\ShortestPath\BLL\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件       1344  2016-06-18 23:34  ShortestPathEngine\ShortestPath\BLL\Properties\AssemblyInfo.cs

     文件      15396  2016-06-19 14:29  ShortestPathEngine\ShortestPath\BLL\ShortestPathEngine.cs

     文件      37811  2016-06-19 14:36  ShortestPathEngine\ShortestPath\BLL\ShortestPathEngineV1.cs

     文件        187  2016-06-18 23:34  ShortestPathEngine\ShortestPath\ShortestPath\App.config

     文件      22016  2016-06-19 14:36  ShortestPathEngine\ShortestPath\ShortestPath\bin\Debug\BLL.dll

     文件      56832  2016-06-19 14:36  ShortestPathEngine\ShortestPath\ShortestPath\bin\Debug\BLL.pdb

     文件      13824  2016-06-19 14:50  ShortestPathEngine\ShortestPath\ShortestPath\bin\Debug\ShortestPath.exe

     文件        187  2016-06-18 23:34  ShortestPathEngine\ShortestPath\ShortestPath\bin\Debug\ShortestPath.exe.config

     文件      28160  2016-06-19 14:50  ShortestPathEngine\ShortestPath\ShortestPath\bin\Debug\ShortestPath.pdb

     文件      22984  2016-06-19 13:12  ShortestPathEngine\ShortestPath\ShortestPath\bin\Debug\ShortestPath.vshost.exe

     文件        187  2016-06-18 23:34  ShortestPathEngine\ShortestPath\ShortestPath\bin\Debug\ShortestPath.vshost.exe.config

     文件        490  2012-06-06 02:06  ShortestPathEngine\ShortestPath\ShortestPath\bin\Debug\ShortestPath.vshost.exe.manifest

     文件       5040  2016-06-19 14:50  ShortestPathEngine\ShortestPath\ShortestPath\Form1.cs

     文件      11822  2016-06-19 14:50  ShortestPathEngine\ShortestPath\ShortestPath\Form1.Designer.cs

     文件       8421  2016-06-19 14:50  ShortestPathEngine\ShortestPath\ShortestPath\Form1.resx

     文件       1167  2016-06-19 11:25  ShortestPathEngine\ShortestPath\ShortestPath\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7082  2016-06-18 23:42  ShortestPathEngine\ShortestPath\ShortestPath\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        978  2016-06-19 14:22  ShortestPathEngine\ShortestPath\ShortestPath\obj\Debug\ShortestPath.csproj.FileListAbsolute.txt

     文件        975  2016-06-19 14:50  ShortestPathEngine\ShortestPath\ShortestPath\obj\Debug\ShortestPath.csproj.GenerateResource.Cache

     文件       6734  2016-06-19 14:36  ShortestPathEngine\ShortestPath\ShortestPath\obj\Debug\ShortestPath.csprojResolveAssemblyReference.cache

............此处省略36个文件信息

评论

共有 条评论