public IActionResult Calculation()
        {
            var graph = new OrientedGraph(new RelationsAdapter(Request.Query).Adapt());

            var adjMatrix = graph.ToMatrix();

            var graphInfo         = new GraphInfo(graph);
            var taktsOfCreation   = graphInfo.TactsOfCreation();
            var taktsOfExtinction = graphInfo.TactsOfExtinction();
            var taktsOfStore      = graphInfo.TactsOfStore();
            var inputs            = graphInfo.Inputs;
            var outputs           = graphInfo.Outputs;
            var power             = graphInfo.Power;

            var powers  = graphInfo.MatricesToZero;
            var bMatrix = new BMatrix(adjMatrix);

            var matrixAdapter    = new MatrixAdapter();
            var graphInfoAdapter = new GraphInfoAdapter();

            return(Json(new
            {
                aMatrices = matrixAdapter.AdaptAdjacencyMatrixWithPowers(powers),
                graphInfo = graphInfoAdapter.AdaptGraphInfo(power, inputs, outputs),
                tactsTable = graphInfoAdapter.AdaptTacts(taktsOfCreation, taktsOfExtinction, taktsOfStore),
                bMatrix = matrixAdapter.AdaptBMatrix(bMatrix)
            }));
        }
Beispiel #2
0
 public void AdjacencyMatrix()
 {
     Assert.AreEqual(new[]
     {
         new [] { 0, 1, 1, 1 },
         new [] { 0, 0, 0, 0 },
         new [] { 0, 1, 0, 0 },
         new [] { 0, 0, 0, 0 }
     }, _graph.ToMatrix().ToArray());
 }
Beispiel #3
0
        public void BMatrixTest()
        {
            var bMatrix = new BMatrix(_graph.ToMatrix()).ToArray();

            var res = new[]
            {
                new[] { 0, 1, 1, 0, 0, 0, 1, 0 },
                new[] { 0, 0, 1, 0, 0, 0, 1, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 1, 2, 2, 0, 0, 0, 2, 0 },
                new[] { 0, 1, 1, 0, 0, 0, 1, 0 },
                new[] { 1, 2, 2, 1, 0, 0, 2, 0 },
                new[] { 0, 0, 0, 0, 0, 0, 0, 0 },
                new[] { 0, 1, 1, 0, 1, 0, 1, 0 }
            };

            Assert.AreEqual(res, bMatrix);
        }
Beispiel #4
0
 public GraphInfo(OrientedGraph graph)
 {
     _adjacencyMatrix = graph.ToMatrix();
 }