Ejemplo n.º 1
0
        public void GetShortcuts_ShouldBeEmpty_IfThereAreNoShortcuts()
        {
            var graph  = BuildGraph();
            var result = DiGraphHelper.GetShortcuts(graph);

            result.Should().BeEmpty();
        }
Ejemplo n.º 2
0
        public void GetShortcuts_WhenGraphHasNoLinks_ShouldReturnExpected()
        {
            var graph  = BuildEmptyGraph();
            var result = DiGraphHelper.GetShortcuts(graph);

            result.Should().BeEmpty();
        }
Ejemplo n.º 3
0
        public void GetShortcuts_ShouldFindAllCombinations()
        {
            // This graph has two paths between a and c
            var graph = new Dgml.DirectedGraph
            {
                Nodes = new Dgml.DirectedGraphNode[]
                {
                    BuildNode("a"),
                    BuildNode("b"),
                    BuildNode("c"),
                },
                Links = new Dgml.DirectedGraphLink[]
                {
                    BuildLink("a", "b"),
                    BuildLink("b", "c"),
                    BuildLink("a", "c"),  // Shortcut
                }
            };
            var result = DiGraphHelper.GetShortcuts(graph);

            result.Should().BeEquivalentTo(
                BuildLink("a", "c")
                );
        }