private void SetAdjListNodes(ClassLibrary_Graph.VexNode <string> vexNode, int index) { int i = 0;//计数 for (ClassLibrary_Graph.adjListNode <string> adjListNode = vexNode.FirstAdj; adjListNode != null; adjListNode = adjListNode.Next, i++) { ControlLibrary_Graph.adjListNode adjListNodeControl = new ControlLibrary_Graph.adjListNode(); adjListNodeControl.SetAdjVex(adjListNode.Adjvex); adjListNodeControl.SetWeight(adjListNode.Weight); adjListStackPanel.Children.Add(adjListNodeControl); addLine(150 + 65 + 82 * i, 42 * index + 21, 150 + 5 + 82 + 82 * i, 42 * index + 21); } nullNode nullNodeControl = new nullNode(); adjListStackPanel.Children.Add(nullNodeControl); }
private void SetVexNodes() { for (int i = 0; i < graph.GetNumOfVertex(); i++) { ClassLibrary_Graph.VexNode <string> vexNode = graph.GetVexNode(i); ControlLibrary_Graph.VexNode vexNodeControl = new ControlLibrary_Graph.VexNode(); vexNodeControl.SetIndex(i); vexNodeControl.SetData(vexNode.Data.Data); vexNodeControl.SetIndegree(vexNode.Indegree); vexNodeControl.SetOutdegree(vexNode.Outdegree); this.VexNodeStackPanel.Children.Add(vexNodeControl); adjListStackPanel = new StackPanel(); adjListStackPanel.Orientation = Orientation.Horizontal; adjListStackPanel.HorizontalAlignment = HorizontalAlignment.Left; SetAdjListNodes(vexNode, i); this.allAdjListStackPanel.Children.Add(adjListStackPanel); addLine(123, 42 * i + 21, 155, 42 * i + 21); } }