public void Initialize(VerificationContext context, Graph graph)
        {
            this.aggregateForMethod = new Dictionary<MethodNode, AggregateNode>();

            var bfs = new LambdaBreadthFirstSearch<Node, Link>
            {
                AvailableTargets = n => n.OutboundLinks
                    .Where(l => l is HasOneEntityLink || l is HasManyEntityLink)
                    .GroupBy(x => x.Target)
                    .Union(n.InboundLinks.Where(l => l is ContainedInLink && l.Target is EntityNode && l.Source is MethodNode).GroupBy(x => x.Source))
            };

            var aggregates = graph.Nodes.OfType<AggregateNode>();

            foreach (var node in aggregates)
            {
                bfs.HandlingNode = (n, _) =>
                {
                    var methodNode = n as MethodNode;
                    if (methodNode != null && !methodNode.Method.IsSpecialName)
                    {
                        this.aggregateForMethod[methodNode] = node;
                    }
                };

                bfs.Walk(node);
            }
        }
        public void AcyclicGraph()
        {
            // arrange
            var graph = new Graph();

            var a = graph.AddNode(new SampleNode("a"));
            var b = graph.AddNode(new SampleNode("b"));
            var c = graph.AddNode(new SampleNode("c"));
            var d = graph.AddNode(new SampleNode("d"));
            var e = graph.AddNode(new SampleNode("e"));
            var f = graph.AddNode(new SampleNode("f"));
            var g = graph.AddNode(new SampleNode("g"));
            var h = graph.AddNode(new SampleNode("h"));

            graph.AddLink(a, b, new SampleLink());
            graph.AddLink(a, c, new SampleLink());
            graph.AddLink(b, d, new SampleLink());
            graph.AddLink(b, e, new SampleLink());
            graph.AddLink(c, f, new SampleLink());
            graph.AddLink(c, g, new SampleLink());
            graph.AddLink(e, h, new SampleLink());

            // act
            var path = new List<Node>();

            var collectVisitedNodes = new LambdaBreadthFirstSearch<Node, Link>
            {
                HandlingNode = (node, links) => path.Add(node)
            };

            collectVisitedNodes.Walk(a);

            // assert
            Assert.That(path, Is.EqualTo(new[] { a, b, c, d, e, f, g, h }));
        }
        public void Initialize(VerificationContext context, Graph graph)
        {
            var entryPoint = graph.LookupNode<ApplicationEntryPoint>(ApplicationEntryPoint.NodeId);

            this.unusedCommands = new HashSet<CommandNode>(graph.Nodes.OfType<CommandNode>());

            var bfs = new LambdaBreadthFirstSearch<Node, Link>
            {
                HandlingNode = (node, links) =>
                {
                    var commandNode = node as CommandNode;
                    if (commandNode != null && links.OfType<ExecuteCommandLink>().Any())
                    {
                        this.unusedCommands.Remove(commandNode);
                    }
                }
            };

            bfs.Walk(entryPoint);
        }