setWeight() public method

public setWeight ( AST node, int weight ) : void
node AST
weight int
return void
Exemplo n.º 1
0
        private static int PropagateNodeWeight(AST.Address node, DAG dag)
        {
            // if the node is a formula, recursively
            // compute its weight
            if (dag.isFormula(node))
            {
                // get input nodes
                var vector_rngs = dag.getFormulaInputVectors(node);
                var scinputs    = dag.getFormulaSingleCellInputs(node);
                var inputs      = vector_rngs.SelectMany(vrng => vrng.Addresses()).ToList();
                inputs.AddRange(scinputs);

                // call recursively and sum components
                var weight = 0;
                foreach (var input in inputs)
                {
                    weight += PropagateNodeWeight(input, dag);
                }
                dag.setWeight(node, weight);
                return(weight);
            }
            // node is an input
            else
            {
                dag.setWeight(node, 1);
                return(1);
            }
        }
Exemplo n.º 2
0
        // Propagate weights
        private static void PropagateWeights(DAG dag)
        {
            if (dag.containsLoop())
            {
                throw new ContainsLoopException();
            }

            // starting set of functions; roots in the forest
            var formulas = dag.terminalFormulaNodes(false);

            // for each forest
            foreach (AST.Address f in formulas)
            {
                dag.setWeight(f, PropagateNodeWeight(f, dag));
            }
        }
Exemplo n.º 3
0
        // Propagate weights
        private static void PropagateWeights(DAG dag)
        {
            if (dag.containsLoop())
            {
                throw new ContainsLoopException();
            }

            // starting set of functions; roots in the forest
            var formulas = dag.terminalFormulaNodes(false);

            // for each forest
            foreach (AST.Address f in formulas)
            {
                dag.setWeight(f, PropagateNodeWeight(f, dag));
            }
        }
Exemplo n.º 4
0
        private static int PropagateNodeWeight(AST.Address node, DAG dag)
        {
            // if the node is a formula, recursively
            // compute its weight
            if (dag.isFormula(node))
            {
                // get input nodes
                var vector_rngs = dag.getFormulaInputVectors(node);
                var scinputs = dag.getFormulaSingleCellInputs(node);
                var inputs = vector_rngs.SelectMany(vrng => vrng.Addresses()).ToList();
                inputs.AddRange(scinputs);

                // call recursively and sum components
                var weight = 0;
                foreach (var input in inputs)
                {
                    weight += PropagateNodeWeight(input, dag);
                }
                dag.setWeight(node, weight);
                return weight;
            }
            // node is an input
            else
            {
                dag.setWeight(node, 1);
                return 1;
            }
        }