Пример #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            ResetLabel();
            ResetTextBox();
            textBox1.Text = "";
            textBox4.Text = "";
            string  beginName = textBox2.Text;
            string  endName   = textBox3.Text;
            VexInfo beginVex  = G.CheckInfo(beginName);
            VexInfo endVex    = G.CheckInfo(endName);

            if (beginVex == null || endVex == null)
            {
                richTextBox1.Text = "未找到该地名";
                return;
            }
            int[]         vexLocation;
            StringBuilder str = G.PathOneToOthers(beginName, endName, out vexLocation);

            for (int i = 0; i < vexLocation.Length; i++)
            {
                labels.ElementAt(vexLocation[i]).ForeColor = Color.Red;
            }
            richTextBox1.Text = str.ToString();
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            ResetLabel();
            ResetTextBox();
            textBox2.Text = "";
            textBox3.Text = "";
            textBox1.Text = "";
            string  name    = textBox4.Text;
            VexInfo vexInfo = G.CheckInfo(name);

            if (vexInfo == null)
            {
                richTextBox1.Text = "未找到该地名!请重新输入!";
                return;
            }
            richTextBox1.Text = "地名:" + vexInfo.name + "    地点信息:" + vexInfo.introduction;
            for (int i = 0; i < labels.Count; i++)
            {
                if (labels.ElementAt(i).Text.Equals(vexInfo.name))
                {
                    labels.ElementAt(i).ForeColor = Color.Red;
                    break;
                }
            }
        }
Пример #3
0
        public Graph()
        {
            string[] vexsNames         = new string[] { "大门", "体育馆", "主楼", "联通广场", "游泳馆", "音乐厅", "图书馆", "家属区", "田径场", "实验楼", "文博馆", "餐厅", "篮球场" };
            string[] vexsIntroductions = new string[] { "A区大门", "集比赛、运动、集会的综合性场馆", "行政办公", "由中国联通赞助", "游泳场所", "文艺演出、观影场所", "借阅图书和自习", "家属、职工住宅区", "田径运动场所", "各门学科实验场所", "参观黑大校史", "吃饭", "打篮球" };
            vexs = new VexInfo[vexsNames.Length];
            arcs = new int[vexsNames.Length, vexsNames.Length];
            for (int i = 0; i < vexs.Length; i++)
            {
                vexs[i]              = new VexInfo();
                vexs[i].no           = i;
                vexs[i].name         = vexsNames[i];
                vexs[i].introduction = vexsIntroductions[i];
            }
            for (int i = 0; i < vexsNames.Length; i++)
            {
                for (int j = 0; j < vexsNames.Length; j++)
                {
                    arcs[i, j] = INFINITE;
                }
            }
            vexsNum = vexsNames.Length;
            arcsNum = 25;

            arcs[0, 1] = 2;
            arcs[0, 2] = 1;
            arcs[1, 2] = 2;
            arcs[1, 4] = 4;
            arcs[2, 4] = 2;
            arcs[2, 3] = 1;
            arcs[3, 4] = 2;
            arcs[4, 5] = 2;
            arcs[3, 5] = 2;
            arcs[3, 6] = 1;

            arcs[5, 6]  = 1;
            arcs[5, 7]  = 1;
            arcs[6, 7]  = 2;
            arcs[6, 8]  = 1;
            arcs[6, 9]  = 2;
            arcs[7, 8]  = 1;
            arcs[3, 9]  = 3;
            arcs[3, 10] = 5;
            arcs[9, 10] = 3;
            arcs[9, 11] = 1;

            arcs[10, 11] = 2;
            arcs[11, 12] = 2;
            arcs[9, 12]  = 2;
            arcs[8, 9]   = 2;
            arcs[8, 12]  = 5;
            for (int i = 0; i < vexsNum; i++)
            {
                for (int j = 0; j < vexsNum; j++)
                {
                    arcs[j, i] = arcs[i, j];
                }
            }
        }
Пример #4
0
        private void button2_Click(object sender, EventArgs e)
        {
            ResetLabel();
            ResetTextBox();
            textBox2.Text = "";
            textBox3.Text = "";
            textBox4.Text = "";
            string  name    = textBox1.Text;
            VexInfo vexInfo = G.CheckInfo(name);

            if (vexInfo == null)
            {
                richTextBox1.Text = "未找到路径!请重新输入!";
                return;
            }
            int[]         vexLocation;
            StringBuilder str = G.PathGateToOthers(name, out vexLocation);

            for (int i = 0; i < vexLocation.Length; i++)
            {
                labels.ElementAt(vexLocation[i]).ForeColor = Color.Red;
            }
            richTextBox1.Text = str.ToString();
        }