Ejemplo n.º 1
0
        private void GraphViewer_MouseUp(object sender, MsaglMouseEventArgs e)
        {
            string selectedNode = lastSelectedId;

            CheckObject();
            if (!string.IsNullOrWhiteSpace(lastSelectedId))
            {
                int lastSelectedGraphId = int.Parse(lastSelectedId);
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    if (!string.IsNullOrWhiteSpace(selectedNode))
                    {
                        var first  = graph.FindVertex(selectedNode);
                        var second = graph.FindVertex(lastSelectedId);

                        if (first?.Degree == 0 || second?.Degree == 0)
                        {
                            graph.ConnectVertex(first, second);
                        }
                    }
                    else
                    {
                        var vertex = graph.AddVertex();
                        graph.ConnectVertex(lastSelectedGraphId, vertex.Id);
                    }
                    DrawGraph();
                }
                else if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
                {
                    graph.RemoveVertex(graph.Vertices.Where(x => x.Id == lastSelectedGraphId).FirstOrDefault());
                    DrawGraph();
                }
            }
        }
Ejemplo n.º 2
0
        private void GenerateStartGraph()
        {
            graph = new GraphCore();

            for (int i = 0; i < 6; i++)
            {
                graph.AddVertex();
            }

            graph.ConnectVertex(1, 4);
            graph.ConnectVertex(2, 4);
            graph.ConnectVertex(3, 4);
            graph.ConnectVertex(4, 5);
            graph.ConnectVertex(5, 6);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var graph = new GraphCore();

            for (int i = 0; i < 6; i++)
            {
                graph.AddVertex();
            }

            graph.ConnectVertex(1, 4);
            graph.ConnectVertex(2, 4);
            graph.ConnectVertex(3, 4);
            graph.ConnectVertex(4, 5);
            graph.ConnectVertex(5, 6);

            Console.WriteLine(string.Join(";", graph.GeneratePruferCode()));

            Console.ReadKey();
        }
Ejemplo n.º 4
0
 private void GenerateGraphFromPruferCode_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     graph.AddVertex();
     DrawGraph();
 }