コード例 #1
0
        public void ConstructorTest()
        {
            MatrixRepresentation listRepresentation = new MatrixRepresentation(5);

            if (listRepresentation.Nodes != 5)
            {
                Assert.Fail();
            }
        }
コード例 #2
0
        public void AddEdgeTest()
        {
            MatrixRepresentation listRepresentation = new MatrixRepresentation(5);

            listRepresentation.AddEdge(new Edge(1, 2, 5));
            listRepresentation.AddEdge(new Edge(3, 1, 5));
            if (listRepresentation.Edges != 2)
            {
                Assert.Fail();
            }
        }
コード例 #3
0
        public void GetEdgesTest()
        {
            MatrixRepresentation listRepresentation = new MatrixRepresentation(5);

            listRepresentation.AddEdge(new Edge(1, 2, 5));
            listRepresentation.AddEdge(new Edge(3, 1, 5));
            listRepresentation.AddEdge(new Edge(1, 3, 5));
            listRepresentation.AddEdge(new Edge(1, 4, 5));
            if (listRepresentation.GetEdges(1).Count != 3)
            {
                Assert.Fail();
            }
        }
コード例 #4
0
        private void ComputeMatrix()
        {
            MatrixRepresentation matrixRepresentation = (MatrixRepresentation)representation;

            for (int i = 0; i < NUMBER_OF_NODES; i++)
            {
                for (var j = 0; j < NUMBER_OF_NODES; j++)
                {
                    var edge = matrixRepresentation.Matrix[i, j];
                    if (edge != null)
                    {
                        ShortestPathTable[i, j] = edge.Weight;
                        Previous[i, j]          = i;
                    }
                }
            }
        }