Example #1
0
 public OutPoint AddOutConnection()
 {
     var outConn = new OutPoint(this);
     Output.Add(outConn);
     outConn.Name = Name + " Outpoint"+Output.Count.ToString(CultureInfo.InvariantCulture);
     return outConn;
 }
Example #2
0
 public static GraphConnection Connect(OutPoint outPoint, InPoint inPoint, int length = 1)
 {
     if (outPoint == null || inPoint == null)
         return null;
     var connection = new GraphConnection(length, outPoint, inPoint);
     connection.Name = outPoint.Name + " connection";
     outPoint.AddConection(connection);
     inPoint.AddConection(connection);
     if (string.IsNullOrEmpty(inPoint.Name))
         inPoint.Name = outPoint.Name + " connection inPoint";
     return connection;
 }
Example #3
0
        /*
         *  var firstTryNode = new ActionNode(delegate(List<IntColor> colors, List<Color> badColors)
                {
                    var sum = colors.Sum(color => color.Value);
                    return sum < 5 ? (Color) null : new IntColor(sum);
                });
            var secondTryNode = new ActionNode(delegate(List<IntColor> colors, List<Color> badColors)
            {
                var sum = colors.Sum(color => color.Value);
                return sum < 10 ? (Color)null : new IntColor(sum);
            });
         */
        static string Compare(int x, int compareWith)
        {
            var xPoint = new OutPoint(new IntColor(x)) { Name = "xPoint" };
            var compareWithPoint = new OutPoint(new IntColor(compareWith)) { Name = "compareWithPoint" };

            var comparisonNodeLess = new CompareNode() { Name = "comparisonNodeLess" };
            var comparisonNodeMore = new CompareNode() { Name = "comparisonNodeMore" };
            var comparisonNodeEquals = new CompareNode() { Name = "comparisonNodeEquals" };

            xPoint.ConnectTo(comparisonNodeLess);
            xPoint.ConnectTo(comparisonNodeMore);
            xPoint.ConnectTo(comparisonNodeEquals);

            compareWithPoint.ConnectTo(comparisonNodeLess.CompareWith);
            compareWithPoint.ConnectTo(comparisonNodeMore.CompareWith);
            compareWithPoint.ConnectTo(comparisonNodeEquals.CompareWith);

            new OutPoint(new CompareColor(CompareType.Less)) { Name = "CompareType.Less" }.ConnectTo(comparisonNodeLess.CompareOperation);
            new OutPoint(new CompareColor(CompareType.More)) { Name = "CompareType.More" }.ConnectTo(comparisonNodeMore.CompareOperation);
            new OutPoint(new CompareColor(CompareType.Equal)) { Name = "CompareType.Equal" }.ConnectTo(comparisonNodeEquals.CompareOperation);

            var mix1 = new MixNode() { Name = "mix1" };
            var mix2 = new MixNode() { Name = "mix2" };
            var mix3 = new MixNode() { Name = "mix3" };

            comparisonNodeLess.ConnectTo(mix1);
            comparisonNodeMore.ConnectTo(mix2);
            comparisonNodeEquals.ConnectTo(mix3);

            new OutPoint(new StringColor("Less")) { Name = "LessString" }.ConnectTo(mix1);
            new OutPoint(new StringColor("More")) { Name = "MoreString" }.ConnectTo(mix2);
            new OutPoint(new StringColor("Equals")) { Name = "EqualsString" }.ConnectTo(mix3);
            //comparisonNodeEquals.AddOutConnection().ConnectTo(new OutPoint(new StringColor("Equal")));

            //both x and y will recieve the same result in this text, so add just one of them
            graph.Add(xPoint);
            string res = "";
            graph.OnFinish += delegate(GraphResult result)
                {
                    GraphPath path = result[xPoint];
                    if (path != null)
                    {
                        //sum is list of transitions of first value — result is the last one.
                        res = path.LastColor.ToStringDemuxed();
                    }

                };
            graph.Start();
            return res;
        }
Example #4
0
        static void Test()
        {
            //Calculate x+y
            var summ = new Summator();
            var summ2 = new Summator();
            var summ3 = new Summator();
            var str = new Stringer();

            var one = new InPoint(new IntColor(1));
            var one2 = new OutPoint(new IntColor(1));
            var two = new InPoint(new IntColor(2));
            var three = new OutPoint(new IntColor(3));
            var four = new OutPoint(new IntColor(5));
            var mix1 = new MixNode();

            one.ConnectTo(summ);
            two.ConnectTo(summ);

            one2.ConnectTo(summ).ConnectTo(summ2);
            three.ConnectTo(summ2).ConnectTo(str);

            four.ConnectTo(summ2);
            summ.ConnectTo(summ3);
            summ2.ConnectTo(summ3);
            summ3.ConnectTo(str);
            new OutPoint(new IntColor(6)).ConnectTo(str);
            //str.ConnectTo(mix1);
            // new OutPoint(new StringColor("abba")).ConnectTo(mix1);/**/
            // graph.Add(new ColorableClass[] { one, two, one2, three });
            graph.Add(new ConnectionPoint[] { one, two, one2, three, four });
            graph.OnFinish += OnFinish;
            graph.StartAsync();
        }
Example #5
0
 public override ColorableClass ConnectTo(OutPoint to, int length = 1)
 {
     to.AddConection(this);
     return this;
 }
Example #6
0
 public GraphConnection(int length, OutPoint from, InPoint to)
 {
     Length = length;
     From = from;
     To = to;
 }
Example #7
0
 public override ColorableClass ConnectTo(OutPoint to, int length = 1)
 {
     return this;
 }
Example #8
0
 public virtual ColorableClass ConnectTo(OutPoint to, int length = 1)
 {
     return this;
 }
Example #9
0
 public GraphNode()
 {
     Input.OnAllFiltered += OnAllInputsFlowed;
     Output = new OutPoint(this);
 }
Example #10
0
 public virtual ColorableClass ConnectTo(OutPoint to, int length = 1)
 {
     return(this);
 }