public void FindLongPaths_WhenGraphHasNoLinks_ShouldReturnExpected() { var graph = BuildEmptyGraph(); var result = DiGraphHelper.FindLongPaths(graph); result.Should().BeEmpty(); }
public void FindLongPaths_ShouldReturnExpected() { var graph = BuildGraph(); var result = DiGraphHelper.FindLongPaths(graph); result.Should().BeEquivalentTo((new DiNodePair("a", "c"))); }
public void GetNeighbors_WhenGraphHasNoLinks_ShouldReturnExpected() { var graph = BuildEmptyGraph(); var result = DiGraphHelper.GetDiNeighbors(graph); result.Should().BeEmpty(); }
public void GetShortcuts_ShouldBeEmpty_IfThereAreNoShortcuts() { var graph = BuildGraph(); var result = DiGraphHelper.GetShortcuts(graph); result.Should().BeEmpty(); }
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") ); }
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(); }
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"); }
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") ); }