예제 #1
0
    public static void TraverseTree(DecisionTree root, StringBuilder sb, int nodeNum, Operand op)
    {
        if (root == null)
        {
            return;
        }
        List <TreeEdge> edges = root.GetAllEdges();

        sb.Append(@"g.addNode(" + nodeNum + ", { label : '" + root.node.value + "' });");

        if (edges.Count == 0)
        {
            //Base Case: if no more edges, return
            return;
        }
        else
        {
            foreach (TreeEdge edge in edges)
            {
                //Recursive Case: for each edge, recurse on their nodes and add edges to them
                int nextNum = rnd.Next(0, int.MaxValue);
                //Color the edges
                if (op.Evaluate(root.node.value, edge.value))
                {
                    TraverseTree(edge.GetTChildTree(), sb, nextNum, op);
                    sb.Append(@"g.addEdge(" + nodeNum + ", " + nextNum + ", { directed : true,  stroke : '#bfa' , fill : '#56f', label : '" + edge.value.ToString() + "' });");
                }
                else
                {
                    TraverseTree(edge.GetTChildTree(), sb, nextNum, Operand.Clone(op).Fail());
                    sb.Append(@"g.addEdge(" + nodeNum + ", " + nextNum + ", { directed : true, label : '" + edge.value.ToString() + "' });");
                }
            }
        }
    }
예제 #2
0
    private DecisionTree CreateTree(Queue <String> prioritizedColumns, String currItem, Operand operation)
    {
        //nodeValue = ColumnName
        String nodeValue;
        String debugOperation = " | " + operation.ToString();

        nodeValue = currItem.Equals(prioritizedColumns.Peek()) ? prioritizedColumns.Dequeue() : currItem;

        //DecisionTree node = new DecisionTree(nodeValue + debugOperation);

        if (prioritizedColumns.Count != 0)
        {
            DecisionTree  node           = new DecisionTree(nodeValue);
            List <Object> possibleValues = db.GetDistinctValues(this.tableName, nodeValue, operation);
            String        nextValue      = prioritizedColumns.Peek();
            possibleValues.ForEach(delegate(Object obj){
                Queue <String> queueClone = new Queue <String>();
                prioritizedColumns.ToList <String>().ForEach(i => queueClone.Enqueue(i));
                node.AddEdge(obj, CreateTree(queueClone, nextValue, Operand.Clone(operation).Add(Operand.Comparison.EQUALS, nodeValue, obj)));
            });
            return(node);
        }
        else //Leaf Node so we add one more node for its value
        {
            DecisionTreeLeaf node           = new DecisionTreeLeaf(nodeValue);
            List <Object>    possibleValues = db.GetColumnValues(this.tableName, nodeValue, false, operation);
            node.AddLeafValue(possibleValues);
            node.GetValuesCount().ToList().ForEach(delegate(KeyValuePair <string, int> kv)
            {
                DecisionTreeLeaf leaf = new DecisionTreeLeaf(kv.Key + " : " + kv.Value + debugOperation);
                node.AddEdge(kv.Key, leaf);
            });
            return(node);
        }
    }
예제 #3
0
        public override Expression Clone()
        {
            UnaryExpression result = new UnaryExpression(Operator, Operand.Clone(), instructions);

            result.expressionType = this.expressionType;
            return(result);
        }
예제 #4
0
 public override AstNode Clone()
 {
     return(new TypeOfNode(
                (Context == null ? null : Context.Clone()),
                Parser,
                (Operand == null ? null : Operand.Clone())
                ));
 }
예제 #5
0
 public override AstNode Clone()
 {
     return(new NumericUnary(
                (Context == null ? null : Context.Clone()),
                Parser,
                (Operand == null ? null : Operand.Clone()),
                OperatorToken
                ));
 }
예제 #6
0
 public override AstNode Clone()
 {
     return(new PostOrPrefixOperator(
                Context.Clone(),
                Parser,
                (Operand == null ? null : Operand.Clone()),
                OperatorToken,
                m_postOrPrefixOperator
                ));
 }
예제 #7
0
        internal override object Clone(SqlNodeCloneContext context)
        {
            if (context.NodeMapping.ContainsKey(this))
            {
                return(context.NodeMapping[this]);
            }

            var clone = new SqlCast((SqlExpression)Operand.Clone(context), Type);

            context.NodeMapping[this] = clone;
            return(clone);
        }
예제 #8
0
        /// <summary>
        /// Perform a deep-copy of the current source line.
        /// </summary>
        /// <returns>A clone of the current source line.</returns>
        public SourceLine Clone()
        {
            var copy = new SourceLine(Filename, LineNumber)
            {
                ParsedSource   = ParsedSource,
                UnparsedSource = UnparsedSource,
            };

            if (Label != null)
            {
                copy.Label = Label.Clone();
            }
            if (Instruction != null)
            {
                copy.Instruction = Instruction.Clone();
            }
            if (Operand != null)
            {
                copy.Operand = Operand.Clone();
            }
            return(copy);
        }
예제 #9
0
 public override QueryexBase Clone(string[] prefix = null) => new QueryexUnaryOperator(Operator, Operand.Clone(prefix));
예제 #10
0
 public override Evaluatable <double> Clone() => new NumberWaveFunction
 {
     Operand = Operand.Clone()
 };