Пример #1
0
 public override void Accept(IGraphBuilder <IBuilder> visitor)
 {
     visitor.AddEdge(this, _onResponse, (Keys.Name, "Response"));
     visitor.AddEdge(this, _onException, (Keys.Name, "Exception"));
     _onResponse.Accept(visitor);
     _onException.Accept(visitor);
 }
Пример #2
0
 public override void Accept(IGraphBuilder <IBuilder> visitor)
 {
     base.Accept(visitor);
     visitor.AddEdge(this, _input, (Keys.Name, "Input"));
     visitor.AddEdge(this, _output, (Keys.Name, "Output"));
     _input.Accept(visitor);
     _output.Accept(visitor);
 }
Пример #3
0
            public override void Accept(IGraphBuilder <IBuilder> visitor)
            {
                var type = (_isAlternate ? "Alternate" : "Branch");

                visitor.GetOrAddNode(this, (Keys.Name, $"{type}: {Name}"));
                visitor.AddEdge(this, _trueBranch, (Keys.Name, "True " + type));
                visitor.AddEdge(this, _falseBranch, (Keys.Name, "False" + type));
                _trueBranch.Accept(visitor);
                _falseBranch.Accept(visitor);
            }
Пример #4
0
            public void Accept(IGraphBuilder <IPipe> visitor)
            {
                if (visitor.AddEdge(this, _accept, (Keys.Name, "Accept")))
                {
                    _accept.Accept(visitor);
                }

                if (visitor.AddEdge(this, _deny, (Keys.Name, "Deny")))
                {
                    _deny.Accept(visitor);
                }
            }
        private static void BuildDirectedCyclicGraph(IGraphBuilder graph)
        {
            graph.AddVertex(1);
            graph.AddVertex(2);
            graph.AddVertex(3);

            var edgeId = new IntIdGenerator();

            graph.AddEdge(1, 2, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(2, 3, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(3, 1, edgeId.Next, EdgeDirectionType.Directed);
        }
Пример #6
0
            public void Accept(IGraphBuilder <IPipe> visitor)
            {
                visitor.GetOrAddNode(this, (Keys.Name, _conditionDescription));
                if (visitor.AddEdge(this, _trueBranch, (Keys.Name, "True")))
                {
                    _trueBranch.Accept(visitor);
                }

                if (visitor.AddEdge(this, _falseBranch, (Keys.Name, "False")))
                {
                    _falseBranch.Accept(visitor);
                }
            }
Пример #7
0
 public void Accept(IGraphBuilder <IPipe> visitor)
 {
     if (visitor.AddEdge(this, _next, (Keys.Name, "Next")))
     {
         _next.Accept(visitor);
     }
 }
Пример #8
0
            public void Accept(IGraphBuilder <IPipe> visitor)
            {
                visitor.GetOrAddNode(this, (Keys.Name, _name));
                var list = new List <IPipe>(_cases.Count + 1);

                foreach (var kv in _cases.OrderBy(kv => kv.Key))
                {
                    var target = kv.Value;
                    visitor.AddEdge(this, target, (Keys.Name, $"Case '{kv.Key}':"));
                    list.Add(target);
                }

                visitor.AddEdge(this, _defaultCase, (Keys.Name, $"Default:"));
                list.Add(_defaultCase);
                list.ForEach(p => p.Accept(visitor));
            }
Пример #9
0
            public override void Accept(IGraphBuilder <IBuilder> visitor)
            {
                base.Accept(visitor);

                var list = new List <IBuilder>(_cases.Count + 1);

                foreach (var kv in _cases.OrderBy(x => x.Key))
                {
                    visitor.AddEdge(this, kv.Value, (Keys.Name, $"Case '{kv.Key}':"));
                    list.Add(kv.Value);
                }

                visitor.AddEdge(this, _defaultCase, (Keys.Name, $"Default:"));
                list.Add(_defaultCase);

                list.ForEach(b => b.Accept(visitor));
            }
Пример #10
0
 public void Accept(IGraphBuilder <IPipe> visitor)
 {
     visitor.GetOrAddNode(this, (Keys.Name, _name));
     if (visitor.AddEdge(this, _next, (Keys.Name, "Next")))
     {
         _next.Accept(visitor);
     }
 }
Пример #11
0
            public void Accept(IGraphBuilder <IPipe> visitor)
            {
                var label = $"Remote Procedure Call ({typeof(TRequest).GetCSharpName()} request) => ({typeof(TResponse).GetCSharpName()} response)\nendpoint: {_options.EndPoint}";

                visitor.GetOrAddNode(this, (Keys.Name, label));
                if (visitor.AddEdge(this, _onResponse, (Keys.Name, "Response")))
                {
                    _onResponse.Accept(visitor);
                }

                if (_onException != null)
                {
                    if (visitor.AddEdge(this, _onException, (Keys.Name, "Exception")))
                    {
                        _onException.Accept(visitor);
                    }
                }
            }
Пример #12
0
        private void TestGraphBuilder(IGraphBuilder graph)
        {
            graph.AddVertex(1);
            graph.AddVertex(2);
            graph.AddVertex(3);
            Assert.AreEqual(3, graph.Vertices.Count(), "Adding vertices(3)");

            graph.AddEdge(1, 3, 1);
            graph.AddEdge(2, 1, 2, EdgeDirectionType.Directed);

            Assert.AreEqual(2, graph.Edges.Count(), "Adding edges(2)");

            graph.RemoveVertex(1);
            Assert.AreEqual(2, graph.Vertices.Count(), "Remove vertex(2)");
            Assert.AreEqual(0, graph.Edges.Count(), "After remove vertex");

            Assert.ThrowsException <ArgumentException>(() => graph.RemoveVertex(1));
        }
Пример #13
0
            public void Accept(IGraphBuilder <IPipe> visitor)
            {
                var name = _name ?? $"Transform ({nameof(IContext)}, {typeof(TIn).GetCSharpName()}) => ({nameof(IContext)}, {typeof(TOut).GetCSharpName()})";

                visitor.GetOrAddNode(this, (Keys.Name, name));
                if (visitor.AddEdge(this, _next, (Keys.Name, "Next")))
                {
                    _next.Accept(visitor);
                }
            }
Пример #14
0
 public static void AddEdge(this IGraphBuilder graph, int from, int to, int edge, EdgeDirectionType directionType = EdgeDirectionType.Undirected)
 {
     graph.AddEdge(new Vertex {
         Id = from
     }, new Vertex {
         Id = to
     }, new Edge {
         Id = edge, DirectionType = directionType
     });
 }
Пример #15
0
            public void Accept(IGraphBuilder <IPipe> visitor)
            {
                visitor.GetOrAddNode(this
                                     , (Keys.Name, $"Trace activity '{_name}' ({_kind})")
                                     , ("DiagnosticsName", _name)
                                     , ("DiagnosticsKind", _kind)
                                     , ("DiagnosticsSource", $"{_source.Name} {_source.Version}"));

                if (visitor.AddEdge(this, _next, (Keys.Name, "Next")))
                {
                    _next.Accept(visitor);
                }
            }
Пример #16
0
 public void Accept(IGraphBuilder <IPipe> visitor)
 {
     visitor.GetOrAddNode(this, (Keys.Name, $"Print {typeof(T).GetCSharpName()} to console"));
     visitor.AddEdge(this, _next, (Keys.Name, "Next"));
     _next.Accept(visitor);
 }
 /// <inheritdoc />
 public GraphEdgeBuilder AddEdge(string sourceNode, string destinationNode)
 {
     return(parent.AddEdge(sourceNode, destinationNode));
 }
        private static void BuildDirectedAcyclicGraph(IGraphBuilder graph)
        {
            graph.AddVertex(1);
            graph.AddVertex(2);
            graph.AddVertex(3);
            graph.AddVertex(4);
            graph.AddVertex(5);
            graph.AddVertex(6);
            graph.AddVertex(7);
            graph.AddVertex(8);
            graph.AddVertex(9);
            graph.AddVertex(10);
            graph.AddVertex(11);

            var edgeId = new IntIdGenerator();

            graph.AddEdge(1, 4, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(1, 7, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(1, 11, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(1, 9, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(2, 3, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(2, 4, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(3, 4, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(5, 2, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(8, 5, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(8, 6, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(8, 7, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(9, 10, edgeId.Next, EdgeDirectionType.Directed);
            graph.AddEdge(10, 11, edgeId.Next, EdgeDirectionType.Directed);
        }
        private static void Build3ComponentsUndirectedGraph(IGraphBuilder graph)
        {
            graph.AddVertex(1);
            graph.AddVertex(2);
            graph.AddVertex(3);
            graph.AddVertex(4);
            graph.AddVertex(5);
            graph.AddVertex(6);
            graph.AddVertex(7);
            graph.AddVertex(8);
            graph.AddVertex(9);
            graph.AddVertex(10);
            graph.AddVertex(11);
            graph.AddVertex(12);

            var edgeId = new IntIdGenerator();

            graph.AddEdge(1, 2, edgeId.Next);
            graph.AddEdge(2, 4, edgeId.Next);
            graph.AddEdge(4, 5, edgeId.Next);
            graph.AddEdge(5, 1, edgeId.Next);
            graph.AddEdge(3, 1, edgeId.Next);

            graph.AddEdge(6, 7, edgeId.Next);
            graph.AddEdge(7, 8, edgeId.Next);
            graph.AddEdge(8, 6, edgeId.Next);

            graph.AddEdge(9, 10, edgeId.Next);
            graph.AddEdge(10, 11, edgeId.Next);
            graph.AddEdge(11, 12, edgeId.Next);
            graph.AddEdge(12, 9, edgeId.Next);
        }