Пример #1
0
        private void buttonNewEdge_Click(object sender, EventArgs e)
        {
            NodeWrapper current_node = CurrentSelectedNodeWrapper();

            if (current_node == null)
            {
                return;
            }

            TargetChooser new_edge_dlg = new TargetChooser();

            new_edge_dlg.InitForNewEdge(CurrentGraph, current_node.GraphNode, "Choose destination node for the new edge");
            new_edge_dlg.ShowDialog();
            if (new_edge_dlg.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                current_node.GraphNode.ConnectTo(new_edge_dlg.ChosenNode);
                RebuildEdgeList();
            }
        }
Пример #2
0
        private void buttonFindPath_Click(object sender, EventArgs e)
        {
            NodeWrapper current_node = CurrentSelectedNodeWrapper();

            if (current_node == null)
            {
                return;
            }

            TargetChooser destination_dlg = new TargetChooser();

            destination_dlg.OfferAllNodes(CurrentGraph, "choose destination node for the path"); //, current_node.GraphNode);
            destination_dlg.ShowDialog();
            if (destination_dlg.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                if (destination_dlg.ChosenNode == current_node.GraphNode)
                {
                    MessageBox.Show("That's the same node");
                }
                else
                {
                    List <GlGraphEdge> short_path = CurrentGraph.ShortestPath(current_node.GraphNode, destination_dlg.ChosenNode);
                    if (short_path == null)
                    {
                        MessageBox.Show("No path found");
                    }
                    else
                    {
                        string path_desc = NodeWrapper.GetNodeName(current_node.GraphNode);
                        foreach (GlGraphEdge one_step in short_path)
                        {
                            path_desc += "->" + NodeWrapper.GetNodeName(one_step.TargetNode);
                        }
                        MessageBox.Show(path_desc);
                    }
                }
            }
        }
Пример #3
0
        private void buttonDeleteNode_Click(object sender, EventArgs e)
        {
            NodeWrapper node_to_delete = CurrentSelectedNodeWrapper();

            if (node_to_delete == null)
            {
                return;
            }

            if (!node_to_delete.DeleteNodeFromGraphSafely())
            {
                string confirm_msg = "That node has edges either incoming or outgoing. Delete anyway, along with all related edges?";
                if (MessageBox.Show(confirm_msg, "Confirm", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }
                else
                {
                    node_to_delete.DeleteNodeFromGraphRegardless();
                }
            }

            RebuildNodeList();
        }