コード例 #1
0
        public void FindLongPaths_WhenGraphHasNoLinks_ShouldReturnExpected()
        {
            var graph  = BuildEmptyGraph();
            var result = DiGraphHelper.FindLongPaths(graph);

            result.Should().BeEmpty();
        }
コード例 #2
0
        public void FindLongPaths_ShouldReturnExpected()
        {
            var graph  = BuildGraph();
            var result = DiGraphHelper.FindLongPaths(graph);

            result.Should().BeEquivalentTo((new DiNodePair("a", "c")));
        }
コード例 #3
0
        public void GetNeighbors_WhenGraphHasNoLinks_ShouldReturnExpected()
        {
            var graph  = BuildEmptyGraph();
            var result = DiGraphHelper.GetDiNeighbors(graph);

            result.Should().BeEmpty();
        }
コード例 #4
0
        public void GetShortcuts_ShouldBeEmpty_IfThereAreNoShortcuts()
        {
            var graph  = BuildGraph();
            var result = DiGraphHelper.GetShortcuts(graph);

            result.Should().BeEmpty();
        }
コード例 #5
0
        public void FindLongPaths_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"),
                    BuildNode("d"),
                },
                Links = new Dgml.DirectedGraphLink[]
                {
                    BuildLink("a", "b"),
                    BuildLink("b", "c"),
                    BuildLink("c", "d"),
                }
            };
            var result = DiGraphHelper.FindLongPaths(graph);

            result.Should().BeEquivalentTo(
                new DiNodePair("a", "c"),
                new DiNodePair("b", "d"),
                new DiNodePair("a", "d")
                );
        }
コード例 #6
0
        public void GetNeighbors_ShouldReturnExpected()
        {
            var graph  = BuildGraph();
            var result = DiGraphHelper.GetDiNeighbors(graph);

            result["a"].Should().BeEquivalentTo("b");
            result["b"].Should().BeEquivalentTo("c");
            result["c"].Should().BeEquivalentTo();
        }
コード例 #7
0
        static void Main(string[] args)
        {
            var helpArgs = new string[] { "help", "-help", "/help" };

            if (args.Any(x => helpArgs.Contains(x.ToLower())))
            {
                ShowUsage();
                return;
            }

            _dgmlRepo = new DgmlRepo();
            _merger   = new Merger();

            ProcessArgs(args);
            string[] dgmlsFilePaths          = Directory.GetFiles(_inputFolderPath, "*.dgml");
            List <Dgml.DirectedGraph> graphs = dgmlsFilePaths.Select(f => _dgmlRepo.Load(f)).ToList();

            Dgml.DirectedGraph merged = _merger.Merge(graphs);
            Dgml.DirectedGraph withoutIndirectReferences = DiGraphHelper.RemoveShortcuts(merged);
            _dgmlRepo.Save(withoutIndirectReferences, "Merged.dgml");
        }
コード例 #8
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")
                );
        }