Пример #1
0
        public AddRemoveNode(NodeChangeType nodeChangeType, Node node, Node parent1, Node parent2, List<Node> outputs, Network network)
        {
            if (node == null)
                throw new ArgumentNullException("node");
            if (parent1 == null)
                throw new ArgumentNullException("parent1");
            if (parent2 == null)
                throw new ArgumentNullException("parent2");
            if (outputs == null)
                throw new ArgumentNullException("output");
            //if (node == parent1 || node == parent2 || node == outputs || //TODO: FIX THIS checker
            //    parent1 == parent2 || parent1 == outputs || parent2 == outputs)
            //    throw new ArgumentException();

            nodeChangeType_ = nodeChangeType;
            node_ = node;
            parent1_ = parent1;
            parent2_ = parent2;
            outputs_ = outputs;
            network_ = network;

            // NODE: it is only way I was able to create to make parent 2 children stay in same order after revert
            parent2NodeToInsertAfter_ = null;
            if (nodeChangeType == NodeChangeType.Remove)
            {
                LinkedListNode<Node> parent2LinkedListNodeToInsertAfter = parent2_.Outputs.Find(node_).Previous;
                if (parent2LinkedListNodeToInsertAfter != null)
                {
                    parent2NodeToInsertAfter_ = parent2_.Outputs.Find(node_).Previous.Value;
                }
            }
        }
Пример #2
0
 /// 
 ///     parent2 (not connected)
 ///     
 /// to:
 ///     parent1 ---> _nodeToBeAdded -> output
 ///                  /|
 ///                 /
Пример #3
0
        public void ConnectWithOutput(Node output)
        {
            if (output.Inputs.Count == output.ParentsNo)
                throw new ApplicationException("output node already has all it inputs"); //does not work with ne ParentsNo (1 for copy)

            Outputs.AddLast(output);
            output.Inputs.AddLast(this);
        }
Пример #4
0
        public NodeTypeChange(Node node, NodeType fromType, NodeType toType)
        {
            if (node == null)
                throw new ArgumentNullException("node");

            node_ = node;
            fromType_ = fromType;
            toType_ = toType;
        }
Пример #5
0
 public void TransformNode(Node node, NodeType targetType)
 {
     node.Transform(targetType);
 }
Пример #6
0
 public void RandomlyTransformNode(Node node)
 {
     TransformNode(node, GenerateRandomNodeType());
 }
Пример #7
0
            dummyNetwork.Operations.Add(output);
            dummyNetwork.Operations.Add(child2);
            dummyNetwork.Operations.Add(nodeToBeRemoved);
Пример #8
0
            Assert.AreEqual(1, child3.Inputs.Count);
            Assert.AreEqual(parent1, child3.Inputs.First.Value);
            Assert.AreEqual(0, child3.Outputs.Count);

            dummyNetwork.UTTestingFoo();
        }

        /// <summary>
        /// on graph like:
        /// 
        ///   C1 (1st child of parent1 a.k.a child1
        ///   /\
        ///   ||
        ///   ||
        /// parent1 ---> _nodeToBeRemoved -> output
        ///   ||         /|
        ///   \/        /
        ///   C3       /
        ///           /
        ///  parent2 /
        ///     
        /// it should looke like this after applying patch:
        /// 
        ///  C1 (1st child of parent1 a.k.a child1
        ///   /\
        ///   ||
        ///   ||
        /// parent1 ---> output
        ///   ||         
        ///   \/       
        ///   C3       
        ///           
        ///  parent2        
        ///  
        /// </summary>
        [TestMethod]
        public void AddRemoveNodeRemoveApplyAndRevertWhenNodeToRemoveParent1Has3OutputsTest()
        {
            Node parent1 = new Node(NodeType.add, 0);
            Node parent2 = new Node(NodeType.compare, 0);
            Node child1 = new Node(NodeType.copy, 0);
            Node child3 = new Node(NodeType.copy, 0);
            Node nodeToBeRemoved = new Node(NodeType.inverse, 0);
            Node output = new Node(NodeType.log, 0);
            parent1.ConnectWithOutput(child1);
            parent1.ConnectWithOutput(nodeToBeRemoved);
            parent1.ConnectWithOutput(child3);
            parent2.ConnectWithOutput(nodeToBeRemoved);
            nodeToBeRemoved.ConnectWithOutput(output);
            
            dummyNetwork.Operations.Add(parent1);
            dummyNetwork.Operations.Add(parent2);
            dummyNetwork.Operations.Add(output);
            dummyNetwork.Operations.Add(nodeToBeRemoved);
            AddRemoveNode mutator = new AddRemoveNode(
                nodeChangeType: AddRemoveNode.NodeChangeType.Remove,
                node: nodeToBeRemoved,
                parent1: parent1,
Пример #9
0
            parent1.ConnectWithOutput(nodeToBeRemoved);
            parent2.ConnectWithOutput(nodeToBeRemoved);
            nodeToBeRemoved.ConnectWithOutput(output1);
            nodeToBeRemoved.ConnectWithOutput(output2);

            
            dummyNetwork.Operations.Add(parent1);
            dummyNetwork.Operations.Add(parent2);