Exemplo n.º 1
0
        public ISituationGraphSegment <T> BuildSegment(ISituationGraph <T> Graph, IRule <T> Rule, ISituationPredicate <T> Predicate, IEnumerable <ISituationEdge <T> > Edges)
        {
            SituationNode <T>         node;
            SituationEdge <T>         edge;
            SituationGraphSegment <T> segment;

            if (Graph == null)
            {
                throw new ArgumentNullException("Nodes");
            }
            if (Rule == null)
            {
                throw new ArgumentNullException("Rule");
            }
            if (Predicate == null)
            {
                throw new ArgumentNullException("Predicate");
            }
            if (Edges == null)
            {
                throw new ArgumentNullException("Edges");
            }

            node = CreateNode(Graph);
            Connect(node.AsEnumerable(), Edges);

            edge = CreateEdgeTo(node, Rule, Predicate);

            segment             = new SituationGraphSegment <T>();
            segment.OutputNodes = node.AsEnumerable();
            segment.InputEdges  = edge.AsEnumerable();

            return(segment);
        }
Exemplo n.º 2
0
        public ISituationGraphSegment <T> BuildSegment(ISituationGraph <T> Graph, IRule <T> Rule, IOneOrMorePredicate <T> Predicate, IEnumerable <ISituationEdge <T> > Edges)
        {
            ISituationGraphSegment <T> itemSegment, segment;

            if (Graph == null)
            {
                throw new ArgumentNullException("Nodes");
            }
            if (Rule == null)
            {
                throw new ArgumentNullException("Rule");
            }
            if (Predicate == null)
            {
                throw new ArgumentNullException("Predicate");
            }
            if (Edges == null)
            {
                throw new ArgumentNullException("Edges");
            }

            itemSegment = BuildSegment(Graph, Rule, Predicate.Item, Edges);
            Connect(itemSegment.OutputNodes, itemSegment.InputEdges);


            segment             = new SituationGraphSegment <T>();
            segment.InputEdges  = itemSegment.InputEdges;
            segment.OutputNodes = itemSegment.OutputNodes;

            return(segment);
        }
Exemplo n.º 3
0
        public ISituationGraphSegment <T> BuildSegment(ISituationGraph <T> Graph, IRule <T> Rule, ISequencePredicate <T> Predicate, IEnumerable <ISituationEdge <T> > Edges)
        {
            IEnumerable <ISituationEdge <T> > nextEdges;

            ISituationGraphSegment <T>[] segments;
            ISituationGraphSegment <T>   segment;

            IPredicate <T>[] items;

            if (Graph == null)
            {
                throw new ArgumentNullException("Graph");
            }
            if (Rule == null)
            {
                throw new ArgumentNullException("Rule");
            }
            if (Predicate == null)
            {
                throw new ArgumentNullException("Predicate");
            }
            if (Edges == null)
            {
                throw new ArgumentNullException("Edges");
            }

            items     = Predicate.Items.ToArray();
            segments  = new SituationGraphSegment <T> [items.Length];
            nextEdges = Edges;
            for (int t = items.Length - 1; t >= 0; t--)
            {
                segments[t] = BuildSegment(Graph, Rule, items[t], nextEdges);
                nextEdges   = segments[t].InputEdges;
            }

            segment             = new SituationGraphSegment <T>();
            segment.InputEdges  = segments[0].InputEdges;
            segment.OutputNodes = segments[items.Length - 1].OutputNodes;

            return(segment);
        }
Exemplo n.º 4
0
        public ISituationGraphSegment <T> BuildSegment(ISituationGraph <T> Graph, IRule <T> Rule, IOrPredicate <T> Predicate, IEnumerable <ISituationEdge <T> > Edges)
        {
            ISituationGraphSegment <T>[] segments;
            ISituationGraphSegment <T>   segment;

            IPredicate <T>[] items;

            if (Graph == null)
            {
                throw new ArgumentNullException("Graph");
            }
            if (Rule == null)
            {
                throw new ArgumentNullException("Rule");
            }
            if (Predicate == null)
            {
                throw new ArgumentNullException("Predicate");
            }
            if (Edges == null)
            {
                throw new ArgumentNullException("Edges");
            }

            items    = Predicate.Items.ToArray();
            segments = new SituationGraphSegment <T> [items.Length];
            for (int t = 0; t < items.Length; t++)
            {
                segments[t] = BuildSegment(Graph, Rule, items[t], Edges);
            }

            segment             = new SituationGraphSegment <T>();
            segment.InputEdges  = segments.SelectMany(item => item.InputEdges);
            segment.OutputNodes = segments.SelectMany(item => item.OutputNodes);

            return(segment);
        }