Beispiel #1
0
        public static void DrawEuler(GraphVisual graph, Canvas canvas)
        {
            Point[] vertPositions = graph.vertPositions;

            // Draws indexes in and Euler cycle
            var eulerIdxArray = graph.FindEulerPath();

            if (graph.IsEuler())
            {
                for (int i = 0; i < eulerIdxArray.Count - 1; i++)
                {
                    Label labelEuler = new Label
                    {
#if _ONE_NUMBERING
                        Content = i + 1,
#else
                        Content = i,
#endif
                        Foreground = Brushes.Red
                    };

                    int    nextIdx = i + 1 < eulerIdxArray.Count ? i + 1 : 0;
                    double posX    = (vertPositions[eulerIdxArray[i]].X + vertPositions[eulerIdxArray[nextIdx]].X) / 2;
                    double posY    = (vertPositions[eulerIdxArray[i]].Y + vertPositions[eulerIdxArray[nextIdx]].Y) / 2;
                    Canvas.SetLeft(labelEuler, posX * canvas.ActualWidth - 12);
                    Canvas.SetTop(labelEuler, posY * canvas.ActualHeight - 12);

                    canvas.Children.Add(labelEuler);
                }
            }
        }
Beispiel #2
0
        public MainViewModel()
        {
            GenerateGraphCommand = new RelayCommand(
                delegate
            {
                EulerPathString = "";

                if (UInt32.TryParse(VertCount, out uint vertCount))
                {
                    graph = new GraphVisual(vertCount, (float)EdgeChance, (10, 10), 50);
                }

                NMatrix = graph.NMatrix;

                DrawGraph();
                SetGraphStateMessage();
                if (graph.IsEuler())
                {
                    SetEulerPathString();
                }
            },