示例#1
0
 private void AssertOuters(int[][] outersPerStream, OuterInnerDirectionalGraph graph)
 {
     for (var i = 0; i < outersPerStream.Length; i++)
     {
         EPAssertionUtil.AssertEqualsAnyOrder(outersPerStream[i], graph.GetOuter(i));
     }
 }
示例#2
0
        private static bool RecursiveHasInnerJoin(
            int toStream,
            OuterInnerDirectionalGraph outerInnerGraph,
            InnerJoinGraph innerJoinGraph,
            ICollection <int> completedStreams)
        {
            // Check if the to-stream is in any of the inner joins
            var hasInnerJoin = innerJoinGraph.HasInnerJoin(toStream);

            if (hasInnerJoin)
            {
                return(true);
            }

            var innerToToStream = outerInnerGraph.GetInner(toStream);

            if (innerToToStream != null)
            {
                foreach (int nextStream in innerToToStream)
                {
                    if (completedStreams.Contains(nextStream))
                    {
                        continue;
                    }

                    var notConsider = new HashSet <int>(completedStreams);
                    notConsider.Add(toStream);
                    var result = RecursiveHasInnerJoin(nextStream, outerInnerGraph, innerJoinGraph, notConsider);

                    if (result)
                    {
                        return(true);
                    }
                }
            }

            var outerToToStream = outerInnerGraph.GetOuter(toStream);

            if (outerToToStream != null)
            {
                foreach (int nextStream in outerToToStream)
                {
                    if (completedStreams.Contains(nextStream))
                    {
                        continue;
                    }

                    var notConsider = new HashSet <int>(completedStreams);
                    notConsider.Add(toStream);
                    var result = RecursiveHasInnerJoin(nextStream, outerInnerGraph, innerJoinGraph, notConsider);

                    if (result)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        public void TestGetOuter()
        {
            TryInvalidGetOuter(4);
            TryInvalidGetOuter(-1);

            Assert.IsNull(graph.GetOuter(0));

            graph.Add(0, 1);
            Assert.IsNull(graph.GetOuter(0));
            EPAssertionUtil.AssertEqualsAnyOrder(new int[] { 0 }, graph.GetOuter(1));
            graph.Add(0, 3);
            EPAssertionUtil.AssertEqualsAnyOrder(new int[] { 0 }, graph.GetOuter(3));
            graph.Add(1, 0);
            EPAssertionUtil.AssertEqualsAnyOrder(new int[] { 0 }, graph.GetOuter(1));
            EPAssertionUtil.AssertEqualsAnyOrder(new int[] { 1 }, graph.GetOuter(0));
            graph.Add(1, 3);
            graph.Add(2, 3);
            EPAssertionUtil.AssertEqualsAnyOrder(new int[] { 0, 1, 2 }, graph.GetOuter(3));
        }