public void BasicAdjacencyGraph_MinimumCostBetweenTwoNodes_SecondSearch()
        {
            var a = new GraphNode <string>("A");
            var b = new GraphNode <string>("B");
            var c = new GraphNode <string>("C");
            var d = new GraphNode <string>("D");
            var e = new GraphNode <string>("E");

            var stringGraph = new BasicAdjacencyGraph <string>();

            stringGraph.AddEdge(a, b, 6, 6);
            stringGraph.AddEdge(a, d, 1, 1);
            stringGraph.AddEdge(b, d, 2, 2);
            stringGraph.AddEdge(b, e, 2, 2);
            stringGraph.AddEdge(b, c, 5, 5);
            stringGraph.AddEdge(c, e, 5, 5);
            stringGraph.AddEdge(d, e, 1, 1);

            stringGraph.MinimumCostBetweenTwoNodes(a, b); // First search which builds the cache around A
            Assert.AreEqual(1, stringGraph.MinimumCostBetweenTwoNodes(d, e));
        }
        public void BasicAdjacencyGraph_MinimumCostBetweenTwoNodes_Normal()
        {
            var a = new GraphNode <string>("A");
            var b = new GraphNode <string>("B");
            var c = new GraphNode <string>("C");
            var d = new GraphNode <string>("D");
            var e = new GraphNode <string>("E");

            var stringGraph = new BasicAdjacencyGraph <string>();

            stringGraph.AddEdge(a, b, 6, 6);
            stringGraph.AddEdge(a, d, 1, 1);
            stringGraph.AddEdge(b, d, 2, 2);
            stringGraph.AddEdge(b, e, 2, 2);
            stringGraph.AddEdge(b, c, 5, 5);
            stringGraph.AddEdge(c, e, 5, 5);
            stringGraph.AddEdge(d, e, 1, 1);

            Assert.AreEqual(3, stringGraph.MinimumCostBetweenTwoNodes(a, b));
            Assert.AreEqual(1, stringGraph.MinimumCostBetweenTwoNodes(a, d));
            Assert.AreEqual(7, stringGraph.MinimumCostBetweenTwoNodes(a, c));
        }
        public void BasicAdjacencyGraph_MinimumCostBetweenTwoNodes_DestinationNodeNodeHasNoNeighbours()
        {
            var a = new GraphNode <string>("A");
            var b = new GraphNode <string>("B");
            var c = new GraphNode <string>("C");
            var d = new GraphNode <string>("D");
            var e = new GraphNode <string>("E");

            var stringGraph = new BasicAdjacencyGraph <string>();

            stringGraph.AddEdge(a, d, 1, 1);
            stringGraph.AddEdge(c, e, 5, 5);
            stringGraph.AddEdge(d, e, 1, 1);

            Assert.Throws <ConstraintException>(() => stringGraph.MinimumCostBetweenTwoNodes(a, b));
        }
        public void BasicAdjacencyGraph_MinimumCostBetweenTwoNodes_NullDestination()
        {
            var a = new GraphNode <string>("A");
            var b = new GraphNode <string>("B");
            var c = new GraphNode <string>("C");
            var d = new GraphNode <string>("D");
            var e = new GraphNode <string>("E");

            var stringGraph = new BasicAdjacencyGraph <string>();

            stringGraph.AddEdge(a, b, 6, 6);
            stringGraph.AddEdge(a, d, 1, 1);
            stringGraph.AddEdge(b, d, 2, 2);
            stringGraph.AddEdge(b, e, 2, 2);
            stringGraph.AddEdge(b, c, 5, 5);
            stringGraph.AddEdge(c, e, 5, 5);
            stringGraph.AddEdge(d, e, 1, 1);

            Assert.Throws <ArgumentNullException>(() => stringGraph.MinimumCostBetweenTwoNodes(a, null));
        }
        public void BasicAdjacencyGraph_MinimumCostBetweenTwoNodes_DisconnectedGraph()
        {
            var a = new GraphNode <string>("A");
            var b = new GraphNode <string>("B");
            var c = new GraphNode <string>("C");
            var d = new GraphNode <string>("D");
            var e = new GraphNode <string>("E");
            var f = new GraphNode <string>("F");

            var stringGraph = new BasicAdjacencyGraph <string>();

            stringGraph.AddEdge(a, b, 6, 6);
            stringGraph.AddEdge(a, d, 1, 1);
            stringGraph.AddEdge(b, d, 2, 2);
            stringGraph.AddEdge(b, e, 2, 2);
            stringGraph.AddEdge(d, e, 1, 1);
            stringGraph.AddEdge(c, f, 1, 1);


            Assert.Throws <ConstraintException>(() => stringGraph.MinimumCostBetweenTwoNodes(a, c));
        }