Example #1
0
        public void CausalInference_FuseAndCheckForNextIndices1()
        {
            CausalSetSystemBlock testCausalBlock = new CausalSetSystemBlock();

            // fill it
            testCausalBlock.nodes.Add(new CausalSetNode());
            testCausalBlock.indirectionArray.Add(testCausalBlock.getNewIndirectionNumber());
            testCausalBlock.nodes[0].globalIndex = 0;

            testCausalBlock.nodes.Add(new CausalSetNode());
            testCausalBlock.indirectionArray.Add(testCausalBlock.getNewIndirectionNumber());
            testCausalBlock.nodes[1].globalIndex = 1;

            testCausalBlock.nodes.Add(new CausalSetNode());
            testCausalBlock.indirectionArray.Add(testCausalBlock.getNewIndirectionNumber());
            testCausalBlock.nodes[2].globalIndex = 2;

            // 0 -> 2
            // 2 -> 1
            testCausalBlock.nodes[0].next = new CausalIndirectionIndex[] { new CausalIndirectionIndex(2) };
            testCausalBlock.nodes[2].next = new CausalIndirectionIndex[] { new CausalIndirectionIndex(1) };

            CausalSetSystemBlock afterFuse;
            CausalSetSystemBlock fused = CausalSetNodeFuser.fuse(testCausalBlock, out afterFuse, new List <uint> {
                1, 2
            });

            Assert.AreEqual(afterFuse.nodes[0].next.Count, 1);
            Assert.IsTrue(afterFuse.translateIndirectIndexToIndex(testCausalBlock.nodes[0].next[0]) == 1); // first node must point to next one, which got fused
        }
Example #2
0
        public void CausalInference_FuseAsNewSystemBlock4()
        {
            CausalSetSystemBlock testCausalBlock = buildSystemBlock1();

            CausalSetSystemBlock parentAfterFuse;
            CausalSetSystemBlock fused3 = CausalSetNodeFuser.fuse(testCausalBlock, out parentAfterFuse, new uint[] { 2 });

            // node 2 doesn't point to anythin in the subgraph
            Assert.AreEqual(fused3.nodes.Count, 1);
            Assert.AreEqual(fused3.nodes[0].next.Count, 0);
        }
Example #3
0
        public void CausalInference_FuseAsNewSystemBlock1()
        {
            CausalSetSystemBlock testCausalBlock = buildSystemBlock1();
            CausalSetSystemBlock parentAfterFuse;
            CausalSetSystemBlock fused = CausalSetNodeFuser.fuse(testCausalBlock, out parentAfterFuse, new uint[] { 0, 1 });

            // should collapse to an graph 0 --> 1
            Assert.AreEqual(fused.nodes.Count, 2);
            Assert.AreEqual(fused.nodes[0].next.Count, 1);
            Assert.IsTrue(fused.translateIndirectIndexToIndex(fused.nodes[0].next[0]) == 1);

            Assert.AreEqual(fused.nodes[1].next.Count, 0);
        }
Example #4
0
        public void CausalInference_FuseAsNewSystemBlock3()
        {
            CausalSetSystemBlock testCausalBlock = buildSystemBlock1();

            CausalSetSystemBlock parentAfterFuse;
            CausalSetSystemBlock fused2 = CausalSetNodeFuser.fuse(testCausalBlock, out parentAfterFuse, new uint[] { 2, 3 });

            // should collapse to an graph 0 --> 1
            Assert.AreEqual(fused2.nodes.Count, 2);
            Assert.AreEqual(fused2.nodes[0].next.Count, 1);
            Assert.IsTrue(fused2.nodes[0].next[0].value == 1);

            Assert.AreEqual(fused2.nodes[1].next.Count, 0);
        }