Exemple #1
0
        public void FindPathTargetNotExists()
        {
            var graph    = InitGraph();
            var dijkstra = new DijkstraAlhorithm <string, TestVertexData, string, TestEdgeData>(graph);

            Assert.ThrowsException <ItemNotFoundException>(() => dijkstra.FindPaths("L"));
        }
Exemple #2
0
        public void GraphNotExplored()
        {
            var graph    = InitGraph();
            var dijkstra = new DijkstraAlhorithm <string, TestVertexData, string, TestEdgeData>(graph);

            Assert.ThrowsException <GraphNotExploredException>(() => dijkstra.GetPath("T"));
        }
Exemple #3
0
        public void FindPathNullStart()
        {
            var graph    = InitGraph();
            var dijkstra = new DijkstraAlhorithm <string, TestVertexData, string, TestEdgeData>(graph);

            Assert.ThrowsException <ArgumentNullException>(() => dijkstra.FindPaths(null));
        }
        public MainForm()
        {
            InitializeComponent();
            _matrixDialog          = null;
            _drawer                = new DrawGraph();
            _rectangle             = new Rectangle(0, 0, 0, 0);
            _rectangleDrawing      = false;
            _forestGraph           = new Graph <string, VertexData, string, EdgeData>();
            _saved                 = true;
            _graphPath             = new List <string>();
            _dijkstra              = new DijkstraAlhorithm <string, VertexData, string, EdgeData>(_forestGraph);
            _trajectoryMatrix      = new TrajectoryMatrix();
            _trajectoryMatrixReady = false;
            _matrixGeneration      = null;
            _saveFileName          = "";
            _rangeTree             = new RangeTree <VertexData>();
            _binaryFile            = @".\data.bin";
            SetTitle();

#if DEBUG
            _autoloadPath = Directory.GetParent(Environment.CurrentDirectory).Parent.FullName;
#else
            _autoloadPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
#endif
            _autoloadPath += @"\autoload.xml";

            // autoload data
            if (File.Exists(_autoloadPath))
            {
                try
                {
                    DataSerializer.LoadData(_forestGraph, _autoloadPath);
                    graphCanvas.Invalidate();
                    RegenerateTrajectoryMatrix();
                    BuildRangeTree();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Resources.AutoImportError + "\n\nDetail chyby:\n" + ex.Message, Resources.AutoImportErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            Size size = Properties.Settings.Default.MainformSize;
            if (size.Width >= 500 && size.Height >= 300)
            {
                Size = size;
            }

            Point position = Properties.Settings.Default.MainformPosition;
            if (!(position.X <= -1000 && position.Y <= -1000))
            {
                StartPosition = FormStartPosition.Manual;
                Location      = position;
            }
        }
Exemple #5
0
        public void GetPathTest()
        {
            var graph    = InitGraph();
            var dijkstra = new DijkstraAlhorithm <string, TestVertexData, string, TestEdgeData>(graph);

            dijkstra.FindPaths("S");
            var path = dijkstra.GetPath("T");

            CollectionAssert.AreEqual(new List <string>()
            {
                "S", "V3", "V4", "T"
            }, path);
        }
Exemple #6
0
        public void GetPathNoRouteExistsTest()
        {
            var graph    = InitGraph();
            var dijkstra = new DijkstraAlhorithm <string, TestVertexData, string, TestEdgeData>(graph);

            graph.FindEdge("V3", "V4").Block();
            graph.FindEdge("V1", "V2").Block();
            graph.FindEdge("S", "T").Block();

            dijkstra.FindPaths("S");
            var path = dijkstra.GetPath("T");

            CollectionAssert.AreEqual(new List <string>()
            {
            }, path);
        }
Exemple #7
0
        public void GetPathOnInvalidate()
        {
            var graph    = InitGraph();
            var dijkstra = new DijkstraAlhorithm <string, TestVertexData, string, TestEdgeData>(graph);

            dijkstra.FindPaths("S");
            var path = dijkstra.GetPath("T");

            CollectionAssert.AreEqual(new List <string>()
            {
                "S", "V3", "V4", "T"
            }, path);

            dijkstra.Invalidate();
            Assert.ThrowsException <InvalidatedDataException>(() => dijkstra.GetPath("T"));
        }
Exemple #8
0
        public void IgnoreBlockedTest()
        {
            var graph    = InitGraph();
            var dijkstra = new DijkstraAlhorithm <string, TestVertexData, string, TestEdgeData>(graph);

            dijkstra.FindPaths("S", true);

            graph.FindEdge("V3", "V4").Block();
            graph.FindEdge("V1", "V2").Block();
            graph.FindEdge("S", "T").Block();

            Assert.IsFalse(dijkstra.IsInvalidated());

            var path = dijkstra.GetPath("T");

            CollectionAssert.AreEqual(new List <string>()
            {
                "S", "V3", "V4", "T"
            }, path);
        }