Exemplo n.º 1
0
 /// <summary>
 /// 单击搜索按钮的响应
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonGO_Click(object sender, RoutedEventArgs e)
 {
     canvasTree.Children.Clear();            //右繪圖區清理
     canvas.Children.Clear();                //清理左繪圖區
     string[] keyword = textBoxSearch.Text.Split(blank, StringSplitOptions.RemoveEmptyEntries);
     DateTime startTime = DateTime.Now;      //求开始时间
     textBlockInfo.Text = "Start Time:" + startTime.ToString("HH:mm:ss.fff");
     st = new SteinerTree(gm, dbm, keyword);
     st.execute();
     imageDisplay(datagraph.ConstructGeometrySimple(gm, 4, FONTSIZE), Brushes.Black, canvas, false, 1, false);
     imageDisplay(datagraph.ConstructSteinterGeometry(st, gm, 5, FONTSIZE), Brushes.Gold, canvas, false, 2, false);
     imageDisplay(datagraph.ConstructSteinterGeometry(st, gm, 5, FONTSIZE), Brushes.Gold, canvasTree, true, 1, true);
     DateTime endTime = DateTime.Now;        //求结束时间
     textBlockInfo.Text += "\t" + "End Time" + endTime.ToString("HH:mm:ss.fff");
     textBlockInfo2.Text = "Duration: " + (endTime - startTime).Milliseconds.ToString() + "ms";  //转换为ms
     //buttonMode = 0;                         //改變按鈕形態
     //buttonGO.Content = "GRAPH";             //改变文字
 }
Exemplo n.º 2
0
        /// <summary>
        /// 构造steiner树的几何图形
        /// </summary>
        /// <param name="st">steinertree类</param>
        /// <param name="gm">GraphManager类</param>
        /// <param name="radius">每个点的半径</param>
        /// <param name="fontsize">每个点说明文字的大小</param>
        /// <returns>几何图形组。[0]为点集,[1]为边集</returns>
        public PathGeometry[] ConstructSteinterGeometry(SteinerTree st, GraphManager gm, int radius, int fontsize)
        {
            steinertreeShape = new PathGeometry();
            steinertreeLine = new PathGeometry();
            //i即要绘制的节点
            foreach (int i in st.steinerTreeNode)
            {
                steinertreeShape.AddGeometry(new EllipseGeometry((Point)gm.arrayPos.GetValue(i), radius, radius));
                Point ptext = new Point(((Point)gm.arrayPos.GetValue(i)).X - H_GAP, ((Point)gm.arrayPos.GetValue(i)).Y - V_GAP);
                steinertreeShape.AddGeometry(DataGraphPrintText(gm.arrayKey.GetValue(i).ToString(), ptext, fontsize).BuildGeometry());
            }
            //画线
            foreach (edge i in st.steinerTreeEdge)
            {
                steinertreeLine.AddGeometry(new LineGeometry((Point)gm.arrayPos.GetValue(i.x), (Point)gm.arrayPos.GetValue(i.y)));
            }

            return new PathGeometry[] { steinertreeShape, steinertreeLine };
        }
Exemplo n.º 3
0
 /// <summary>
 /// not implemented yet
 /// </summary>
 /// <param name="st"></param>
 /// <param name="gm"></param>
 /// <param name="radius"></param>
 /// <param name="fontsize"></param>
 /// <returns></returns>
 public PathGeometry[] ConstructSteinterExactGeometry(SteinerTree st, GraphManager gm, int radius, int fontsize)
 {
     throw new NotImplementedException();
 }