Example #1
0
        public void CheckVerticesCount_XmlGenerated()
        {
            var path  = @"../../../testGraph.xml";
            var graph = XmlSource.GetGraphFromXml(path);

            Assert.AreEqual(graph.Vertices.Count, 6);
        }
        public void Is_FindedPath_Shortest_Xml()
        {
            var path  = @"../../../testGraph.xml";
            var graph = XmlSource.GetGraphFromXml(path);

            IVertex <string> kyiv;

            graph.Vertices.TryGetValue(new Vertex <string>()
            {
                Data = "Kyiv"
            }, out kyiv);                                                                //TODO: Write hashset Find or something like this

            IVertex <string> tokyo;

            graph.Vertices.TryGetValue(new Vertex <string>()
            {
                Data = "Tokyo"
            }, out tokyo);

            IVertex <string> lviv;

            graph.Vertices.TryGetValue(new Vertex <string>()
            {
                Data = "Lviv"
            }, out lviv);


            IEdge <string> kl;

            graph.Edges.TryGetValue(new Edge <string>()
            {
                StartNode = kyiv, EndNode = lviv, Distance = 3
            }, out kl);

            IEdge <string> lt;

            graph.Edges.TryGetValue(new Edge <string>()
            {
                StartNode = lviv, EndNode = tokyo, Distance = 1
            }, out lt);
            var expPath = new List <IEdge <string> >()
            {
                kl, lt
            };

            var actualPath = graph.FindShortestPath(kyiv, tokyo).ToList();

            CollectionAssert.AreEqual(expPath, actualPath);
        }