static void Main(string[] args) { Graphs graph = new Graphs(); Node testV1 = new Node("Test1"); Node testV2 = new Node("Test2"); graph.AddNode(testV1); graph.AddNode(testV2); graph.AddEdge(testV1, testV2, 4); List <Node> ordered = graph.BreadFirst(testV1); foreach (Node item in ordered) { Console.Write($"{item.Value} => "); } DGraph dictGraph = new DGraph(); NodeD node1 = new NodeD("Sea"); NodeD node2 = new NodeD("Chi"); dictGraph.AddNode(node1); dictGraph.AddNode(node2); dictGraph.AddEdge(node1, node2, 150); List <DEdge> edges = dictGraph.GetNeighbors(node1); foreach (DEdge item in edges) { Console.Write($"{item} => "); } Console.ReadLine(); }
void Obr() { if (AddNodeBtn.Checked) { PictureBox pictureBox = graph1PB; Graphs gr = graph1; MouseEventArgs mouseEventArgs = FirstClick1; gr.AddNode(mouseEventArgs.X, mouseEventArgs.Y); gr.Draw(pictureBox.CreateGraphics(), selectionNode); } else if (DeleteNodeBtn.Checked) { Graphs gr = graph1; PictureBox pictureBox = graph1PB; MouseEventArgs mouseEventArgs = FirstClick1; Node nodeGrathic = gr.FindNode(mouseEventArgs.Location); if (nodeGrathic != null) { gr.Delete(nodeGrathic); } gr.Draw(pictureBox.CreateGraphics(), selectionNode); } else if (GetEdgeBtn.Checked) { Graphs gr = graph1; PictureBox pictureBox = graph1PB; MouseEventArgs mouseEventArgs1 = FirstClick1; MouseEventArgs mouseEventArgs2 = SecondClick1; Node nodeGrathic1 = gr.FindNode(mouseEventArgs1.Location); Node nodeGrathic2 = gr.FindNode(mouseEventArgs2.Location); if (nodeGrathic1 != null && nodeGrathic2 != null && nodeGrathic1 != nodeGrathic2) { gr.AddEdge(nodeGrathic1, nodeGrathic2); } gr.Draw(pictureBox.CreateGraphics(), selectionNode); } else if (SelectionNodeBtn.Checked) { Node node = graph1.FindNode(FirstClick1.Location); if (node != null) { if (selectionNode.IndexOf(node) != -1) { selectionNode.Remove(node); } else { selectionNode.Add(node); } } graph1.Draw(graph1PB.CreateGraphics(), selectionNode); } }