Exemplo n.º 1
0
        public MainWindow()
        {
            if (Instance == null)
            {
                Instance = this;
            }

            InitializeComponent();



            Graph = GraphGenerator.generatorRegular(2);

            GraphRenderer = new GraphRenderer(Graph, GraphControl, VM);

            GraphListControl.DataContext = new GraphListViewModel();

            GraphControl.OnTwoNodeClickEvent += ConnectTwoNodes;
            GraphControl.OnLineClick         += createWeight;


            Graph.OnChange += onGraphChange;
            onGraphChange();

            this.DataContext = VM;
        }
Exemplo n.º 2
0
        private void GenerateKRegular(object sender, RoutedEventArgs a)
        {
            var window = new CreateRegularWindow();

            window.ShowDialog();
            int nodes      = window.NodesCount;
            int nodeDegree = window.NodeDegree;

            Graph.Set(GraphGenerator.generatorRegular(nodeDegree, nodes));
            Graph.OnChange();
            GraphRenderer.Displayer = new CircleDisplayer();
        }
Exemplo n.º 3
0
        public DirectedWindow()
        {
            InitializeComponent();

            Graph = GraphGenerator.CreateDirectional(GraphGenerator.generatorGER(10, 11));

            Renderer = new DirectionalGraphRenderer(Graph, GraphControl, VM);

            Graph.OnChange                   += onGraphChange;
            GraphControl.OnLineClick         += createWeight;
            GraphControl.OnTwoNodeClickEvent += ConnectTwoNodes;
            Graph.OnChange();

            DataContext = VM;
        }
Exemplo n.º 4
0
        private void GenerateGraph(object sender, RoutedEventArgs args)
        {
            if (sender == ErdosRenyiMenuItem)
            {
                var w = new ErdosGenerator();
                try
                {
                    w.ShowDialog();
                    Graph.Clear();
                    Graph.Set(GraphGenerator.CreateDirectional(w.DataContext as GraphMatrix));
                    Graph.OnChange();
                }
                catch (Exception e)
                {
                    MessageBoxResult result = MessageBox.Show("Coś poszło nie tak"
                                                              + System.Environment.NewLine
                                                              + e.Message
                                                              );
                }
            }
            else if (sender == SecondGeneratorMenuItem)
            {
                var w = new SecondGenerator();
                try
                {
                    w.ShowDialog();
                    Graph.Clear();
                    Graph.Set(GraphGenerator.CreateDirectional(w.DataContext as GraphMatrix));
                    Graph.OnChange();
                }
                catch (Exception e)
                {
                    MessageBoxResult result = MessageBox.Show("Coś poszło nie tak"
                                                              + System.Environment.NewLine
                                                              + e.Message
                                                              );
                }
            }

            Graph.Set(GraphGenerator.CreateRandomDirectedWeights(Graph));
            Graph.OnChange();
            Renderer.Displayer = new DirectedCircleDisplayer();
        }
Exemplo n.º 5
0
 private void SpanningTree(object sender, RoutedEventArgs e)
 {
     Graph.Set(GraphGenerator.Prim(Graph));
     Graph.OnChange();
     GraphRenderer.Displayer = new CircleDisplayer();
 }
Exemplo n.º 6
0
 private void CreateRandomWeights(object sender, RoutedEventArgs e)
 {
     Graph.Set(GraphGenerator.CreateRandomWeights(Graph, 1, 10));
     Graph.OnChange();
 }
Exemplo n.º 7
0
 private void Randomize(object sender, RoutedEventArgs e)
 {
     Graph.Set(GraphGenerator.Randomize(Graph));
     Graph.OnChange();
     GraphRenderer.Displayer = new CircleDisplayer();
 }