/// <summary>
        /// 广度遍历具体算法
        /// </summary>
        /// <param name="graph"></param>
        public void BFSM(ref MatrixGraph graph, int vertex)
        {
            //这里就用系统的队列
            Queue <int> queue = new Queue <int>();

            //先把顶点入队
            queue.Enqueue(vertex);

            //标记此顶点已经被访问
            graph.IsTrav[vertex] = true;

            //输出顶点
            Console.Write(" ->" + graph.Vertexs[vertex]);

            //广度遍历顶点的邻接点
            while (queue.Count != 0)
            {
                var temp = queue.Dequeue();

                //遍历矩阵的横坐标
                for (int i = 0; i < graph.VertexCnt; i++)
                {
                    if (!graph.IsTrav[i] && graph.Edges[temp, i] != 0)
                    {
                        graph.IsTrav[i] = true;

                        queue.Enqueue(i);

                        //输出未被访问的顶点
                        Console.Write(" ->" + graph.Vertexs[i]);
                    }
                }
            }
        }
        /// <summary>
        /// 深度递归的具体算法
        /// </summary>
        /// <param name="graph"></param>
        /// <param name="vertex"></param>
        public void DFSM(ref MatrixGraph graph, int vertex)
        {
            Console.Write("->" + graph.Vertexs[vertex]);

            //标记为已访问
            graph.IsTrav[vertex] = true;

            //要遍历的六个点
            for (int i = 0; i < graph.VertexCnt; i++)
            {
                if (graph.IsTrav[i] == false && graph.Edges[vertex, i] != 0)
                {
                    //深度递归
                    DFSM(ref graph, i);
                }
            }
        }
        /// <summary>
        /// 广度优先
        /// </summary>
        /// <param name="graph"></param>
        public void BFSTraverse(MatrixGraph graph)
        {
            //访问标记默认初始化
            for (int i = 0; i < graph.VertexCnt; i++)
            {
                graph.IsTrav[i] = false;
            }

            //遍历每个顶点
            for (int i = 0; i < graph.VertexCnt; i++)
            {
                //广度遍历未访问过的顶点
                if (!graph.IsTrav[i])
                {
                    BFSM(ref graph, i);
                }
            }
        }
        /// <summary>
        /// 构造图
        /// </summary>
        /// <returns></returns>
        public MatrixGraph CreateGraph()
        {
            //初始化图的信息:顶点个数、边条数、图类型
            Console.WriteLine("请输入创建图的顶点个数,边条数,是否为无向图(0,1来表示),以逗号隔开:");
            List <int>  initData = Console.ReadLine().Split(',').Select(i => int.Parse(i)).ToList();
            MatrixGraph graph    = new MatrixGraph(initData[0], initData[1], initData[2]);

            //请输入各顶点的信息
            Console.WriteLine("请输入各顶点信息:");
            for (int i = 0; i < graph.VertexCnt; i++)
            {
                Console.Write("\n第" + (i + 1) + "个顶点为:");
                string single = Console.ReadLine();
                //顶点信息加入集合中
                graph.Vertexs[i] = single;
            }

            //请输入各边的信息
            Console.WriteLine("\n请输入构成两个顶点的边和权值,以逗号隔开。\n");
            for (int i = 0; i < graph.EdgeCnt; i++)
            {
                Console.Write("第" + (i + 1) + "条边:\t");
                //输入边的起点、终点、权重
                initData = Console.ReadLine().Split(',').Select(j => int.Parse(j)).ToList();
                int start  = initData[0];
                int end    = initData[1];
                int weight = initData[2];

                //给矩阵指定坐标位置赋值
                graph.Edges[start - 1, end - 1] = weight;

                //如果是无向图,则数据呈“二,四”象限对称
                if (graph.GraphType == 1)
                {
                    graph.Edges[end - 1, start - 1] = weight;
                }
            }

            //返回构建完成的图
            return(graph);
        }