예제 #1
0
        private void ConnectPointwise(DrVertexSet source, DrVertexSet destination, ChannelConnectorType type)
        {
            int numberOfSrc = source.Count;
            int numberOfDst = destination.Count;

            if (numberOfDst == 1)
            {
                DrVertex ov     = destination[0];
                int      inputs = ov.GetInputs().GetNumberOfEdges();

                ov.GetInputs().GrowNumberOfEdges(inputs + numberOfSrc);

                for (int i = 0; i < numberOfSrc; i++)
                {
                    DrVertex iv = source[i];

                    int outputs = iv.GetOutputs().GetNumberOfEdges();
                    iv.GetOutputs().GrowNumberOfEdges(outputs + 1);

                    iv.ConnectOutput(outputs, ov, inputs + i, (DrConnectorType)type);
                }
            }
            else if (numberOfSrc == 1)
            {
                DrVertex iv      = source[0];
                int      outputs = iv.GetOutputs().GetNumberOfEdges();

                iv.GetOutputs().GrowNumberOfEdges(outputs + numberOfDst);

                for (int i = 0; i < numberOfDst; i++)
                {
                    DrVertex ov = destination[i];

                    int inputs = ov.GetInputs().GetNumberOfEdges();
                    ov.GetInputs().GrowNumberOfEdges(inputs + 1);

                    iv.ConnectOutput(outputs + i, ov, inputs, (DrConnectorType)type);
                }
            }
            else if (numberOfSrc == numberOfDst)
            {
                for (int i = 0; i < numberOfDst; i++)
                {
                    DrVertex iv = source[i];
                    DrVertex ov = destination[i];

                    int outputs = iv.GetOutputs().GetNumberOfEdges();
                    int inputs  = ov.GetInputs().GetNumberOfEdges();

                    iv.GetOutputs().GrowNumberOfEdges(outputs + 1);
                    ov.GetInputs().GrowNumberOfEdges(inputs + 1);

                    iv.ConnectOutput(outputs, ov, inputs, (DrConnectorType)type);
                }
            }
            else
            {
                throw new LinqToDryadException(String.Format("Source and destination do not match in pointwise connection. Source = {0}, destination = {1}", numberOfSrc, numberOfDst));
            }
        }
예제 #2
0
        private void ConnectCrossProduct(DrVertexSet source, DrVertexSet destination, ChannelConnectorType type)
        {
            int numberOfSrc = source.Count;
            int numberOfDst = destination.Count;

            // Allocate ports
            for (int i = 0; i < numberOfSrc; i++)
            {
                source[i].GetOutputs().SetNumberOfEdges(numberOfDst);
            }

            // Connect them up
            for (int destinationNumber = 0; destinationNumber < numberOfDst; destinationNumber++)
            {
                DrVertex dv     = destination[destinationNumber];
                int      inputs = dv.GetInputs().GetNumberOfEdges();
                dv.GetInputs().GrowNumberOfEdges(inputs + numberOfSrc);

                for (int sourceNumber = 0; sourceNumber < numberOfSrc; sourceNumber++)
                {
                    source[sourceNumber].ConnectOutput(destinationNumber, dv, inputs + sourceNumber, (DrConnectorType)type);
                }
            }
        }