public override Expression Visit(Expression node)
        {
            History.Push(node);

            if (node is BinaryExpression)
            {
                var binary = node as BinaryExpression;
                Visit(binary.Right);
                VisitBinary(binary);
                Visit(binary.Left);
            }
            else if (node is MemberExpression)
            {
                var member = node as MemberExpression;

                if (!Processed.Contains(member))
                {
                    if (!(member.Expression is ParameterExpression))
                    {
                        Visit(member.Expression);
                        Concatenate("of");
                    }

                    VisitMember(member);
                }
            }
            else
            {
                node = base.Visit(node);
            }

            History.Pop();

            return(node);
        }
        private void Concatenate(string value, Expression expression)
        {
            if (Processed.Contains(expression))
            {
                return;
            }

            Result.Push(new { value, expression, expression.NodeType });
            Processed.Add(expression);
        }
        string FindLowestCostNode()
        {
            var    lowestCost     = double.PositiveInfinity;
            string lowestCostNode = null;
            var    nodes          = Costs.Where(n => !Processed.Contains(n.Key));

            foreach (var node in nodes)
            {
                var cost = node.Value;

                if (cost < lowestCost)
                {
                    lowestCost     = cost;
                    lowestCostNode = node.Key;
                }
            }

            return(lowestCostNode);
        }
Beispiel #4
0
        private void BuildPatterns(string pattern)
        {
            if (Processed.Contains(pattern))
            {
                return;
            }
            Processed.Add(pattern);

            string[] groups = pattern.Split('~');
            for (int i = 0; i < groups.Length; i++)
            {
                string v = groups[i];
                if (v == "0" || v == "1" || v == "2")
                {
                    List <string> target = v == "0" ? S1 : (v == "1" ? S2 : S3);
                    BuildSeries(pattern, i, target);
                }
            }
        }
Beispiel #5
0
            public void Execute_BFS()
            {
                BFSQueue.Enqueue(sourceVertex);
                Discovered.Add(sourceVertex.Id);
                Parent.Add(sourceVertex.Id, -1);

                while (BFSQueue.Count != 0)
                {
                    var current = BFSQueue.Dequeue();

                    ProcessVertex_Early(current);

                    Processed.Add(current.Id);

                    foreach (var node in current.AdjacencyList)
                    {
                        if (!Processed.Contains(node.Id))
                        {
                            ProcessEdge(current, node);
                        }

                        if (!Discovered.Contains(node.Id))
                        {
                            Discovered.Add(node.Id);
                            BFSQueue.Enqueue(node);

                            if (!Parent.ContainsKey(node.Id))
                            {
                                Parent[node.Id] = current.Id;
                            }
                            else
                            {
                                Console.WriteLine("We shouldn't be here during BFS");
                            }
                        }
                    }

                    ProcessVertex_Late(current);
                }
            }