• 大小: 83KB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2021-06-16
  • 语言: C/C++
  • 标签:

资源简介

用MFC写的最小生成树算法,可以自由选择结点。更具算法自动显示出最小生成树,非常好用。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
    class AdjMatrix
    {
        public int[] arcs = new int[8 8];
        public int[] vexs = new int[8];
        public int vexnum=0;//点的个数
        public int arcnum=0;//边的个数
        public void CreateAdjMatrix(List s)
        {
            //将图像转换为邻接矩阵
            for (int i = 0; i < s.Count - 1; i++)
            {
                int distance=(int)Math.Floor(Math.Sqrt(Math.Pow(s[i].point.X - s[i + 1].point.X 2) + Math.Pow(s[i].point.Y - s[i + 1].point.Y 2)));
                arcs[s[i].Index s[i + 1].Index] = distance;
                arcs[s[i + 1].Index s[i].Index] = distance;
                arcnum++;
            }
            
            //找到实际连接的点
            int index = 0;
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    if (arcs[i j] != 0)
                    {
                        vexs[index] = i;
                        vexnum++;
                        index++;
                        break;
                    }
                }
            }
         
            
            /*
            string str=““;
            for (int i = 0; i < 8; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    str += arcs[i j].ToString()+“\t“;
                }
                str+=“\n“;
            }
            MessageBox.Show(str); * */
        }
            

    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-12-24 23:01  最小生成树\
     目录           0  2015-12-24 15:25  最小生成树\WindowsFormsApplication1\
     文件        1737  2015-12-21 13:31  最小生成树\WindowsFormsApplication1\AdjMatrix.cs
     文件         959  2015-12-24 23:04  最小生成树\WindowsFormsApplication1\App.config
     文件         298  2015-12-24 23:02  最小生成树\WindowsFormsApplication1\CloseEdge.cs
     文件       10112  2015-12-24 23:21  最小生成树\WindowsFormsApplication1\Form1.Designer.cs
     文件        4362  2015-12-25 08:10  最小生成树\WindowsFormsApplication1\Form1.cs
     文件        6015  2015-12-24 23:21  最小生成树\WindowsFormsApplication1\Form1.resx
     文件        2771  2015-12-25 08:10  最小生成树\WindowsFormsApplication1\Kru.cs
     文件         538  2015-12-24 23:02  最小生成树\WindowsFormsApplication1\Program.cs
     目录           0  2015-12-24 15:25  最小生成树\WindowsFormsApplication1\Properties\
     文件        1392  2015-12-24 23:03  最小生成树\WindowsFormsApplication1\Properties\AssemblyInfo.cs
     文件        3165  2015-12-24 23:05  最小生成树\WindowsFormsApplication1\Properties\Resources.Designer.cs
     文件        5889  2015-12-24 23:05  最小生成树\WindowsFormsApplication1\Properties\Resources.resx
     文件        1552  2015-12-24 23:04  最小生成树\WindowsFormsApplication1\Properties\Settings.Designer.cs
     文件         422  2015-12-24 23:04  最小生成树\WindowsFormsApplication1\Properties\Settings.settings
     文件         413  2015-12-24 23:02  最小生成树\WindowsFormsApplication1\Sites.cs
     文件        4015  2015-12-24 23:05  最小生成树\WindowsFormsApplication1\WindowsFormsApplication1.csproj
     目录           0  2015-12-24 23:04  最小生成树\WindowsFormsApplication1\bin\
     目录           0  2015-12-24 23:08  最小生成树\WindowsFormsApplication1\bin\Debug\
     文件       16384  2015-12-25 08:17  最小生成树\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe
     文件         959  2015-12-24 23:04  最小生成树\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe.config
     文件       67072  2015-12-25 08:17  最小生成树\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.pdb
     文件       22984  2015-12-25 10:58  最小生成树\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe
     文件         959  2015-12-24 23:04  最小生成树\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.config
     文件         490  2012-06-06 02:06  最小生成树\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest
     目录           0  2016-03-05 14:13  最小生成树\WindowsFormsApplication1\bin\Release\
     目录           0  2015-12-24 15:25  最小生成树\WindowsFormsApplication1\obj\
     目录           0  2015-12-25 08:17  最小生成树\WindowsFormsApplication1\obj\Debug\
     文件        1619  2015-12-24 23:04  最小生成树\WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        7043  2015-12-25 10:58  最小生成树\WindowsFormsApplication1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
............此处省略14个文件信息

评论

共有 条评论