public void SimpleAcyclic_A1()
    {
        // Simple acyclic graph.
        var connList = new LightweightList <DirectedConnection>
        {
            new DirectedConnection(0, 3),
            new DirectedConnection(1, 3),
            new DirectedConnection(2, 3),
            new DirectedConnection(2, 4),
            new DirectedConnection(4, 3)
        };

        // Create graph.
        var connSpan = connList.AsSpan();

        connSpan.Sort();
        var digraph = DirectedGraphBuilder.Create(connSpan, 3, 2);

        // Perform depth analysis.
        GraphDepthInfo depthInfo = new CyclicGraphDepthAnalysis().CalculateNodeDepths(digraph);

        // Assertions.
        Assert.Equal(3, depthInfo._graphDepth);
        Assert.Equal(5, depthInfo._nodeDepthArr.Length);

        // Node depths.
        Assert.Equal(0, depthInfo._nodeDepthArr[0]);
        Assert.Equal(0, depthInfo._nodeDepthArr[1]);
        Assert.Equal(0, depthInfo._nodeDepthArr[2]);
        Assert.Equal(2, depthInfo._nodeDepthArr[3]);
        Assert.Equal(1, depthInfo._nodeDepthArr[4]);
    }
Example #2
0
        public void GetTransitiveReduction_HandlesCasesWithMultiplePaths()
        {
            /*
             * ----------|
             * |         V
             * 1 -> 2 -> 3 -> 4
             *      |         ^
             *      ----------|
             */
            var graph = DirectedGraphBuilder <string> .NewBuilder()
                        .AddElement("one")
                        .AddElement("two")
                        .AddElement("three")
                        .AddElement("four")
                        .AddArrow("one", "two")
                        .AddArrow("two", "three")
                        .AddArrow("three", "four")
                        .AddArrow("one", "three")
                        .AddArrow("two", "four")
                        .CreateAcyclicGraphUnsafe();

            /*
             * 1 -> 2 -> 3 -> 4
             */
            var reducedGraph = DirectedAcyclicGraphTransitiveReducer.ReduceGraph(graph);

            reducedGraph.GetDirectSuccessorsOf("one").Should().Contain("two");
            reducedGraph.GetDirectPredecessorsOf("two").Should().Contain("one");
            reducedGraph.GetDirectSuccessorsOf("two").Should().Contain("three");
            reducedGraph.GetDirectPredecessorsOf("three").Should().Contain("two");
            reducedGraph.GetDirectSuccessorsOf("three").Should().Contain("four");
            reducedGraph.GetDirectPredecessorsOf("four").Should().Contain("three");
        }
        public void Regression1()
        {
            // Simple acyclic graph.
            var connList = new LightweightList <DirectedConnection>
            {
                new DirectedConnection(0, 2),
                new DirectedConnection(0, 3),
                new DirectedConnection(0, 4),
                new DirectedConnection(2, 5),
                new DirectedConnection(3, 6),
                new DirectedConnection(4, 7),
                new DirectedConnection(5, 8),
                new DirectedConnection(6, 4),
                new DirectedConnection(6, 9),
                new DirectedConnection(7, 10),
                new DirectedConnection(8, 1),
                new DirectedConnection(9, 1),
                new DirectedConnection(10, 1)
            };

            // Create graph.
            var connSpan = connList.AsSpan();

            connSpan.Sort();
            var digraph = DirectedGraphBuilder.Create(connSpan, 0, 0);

            // Test if cyclic.
            var  cyclicGraphCheck = new CyclicGraphCheck();
            bool isCyclic         = cyclicGraphCheck.IsCyclic(digraph);

            Assert.False(isCyclic);
        }
        public void SimpleCyclic()
        {
            // Simple acyclic graph.
            var connList = new LightweightList <DirectedConnection>
            {
                new DirectedConnection(0, 3),
                new DirectedConnection(1, 3),
                new DirectedConnection(2, 3),
                new DirectedConnection(2, 4),
                new DirectedConnection(4, 1),
                new DirectedConnection(1, 2)
            };

            // Create graph.
            var connSpan = connList.AsSpan();

            connSpan.Sort();
            var digraph = DirectedGraphBuilder.Create(connSpan, 0, 0);

            // Test if cyclic.
            var  cyclicGraphCheck = new CyclicGraphCheck();
            bool isCyclic         = cyclicGraphCheck.IsCyclic(digraph);

            Assert.True(isCyclic);
        }
        public void SimpleCyclic_DefinedNodes_NodeIdGap()
        {
            // Simple acyclic graph.
            var connList = new LightweightList <DirectedConnection>
            {
                new DirectedConnection(100, 103),
                new DirectedConnection(101, 103),
                new DirectedConnection(102, 103),
                new DirectedConnection(102, 104),
                new DirectedConnection(104, 101),
                new DirectedConnection(101, 102)
            };

            // Create graph.
            var connSpan = connList.AsSpan();

            connSpan.Sort();
            var digraph = DirectedGraphBuilder.Create(connSpan, 0, 10);

            // Test if cyclic.
            var  cyclicGraphCheck = new CyclicGraphCheck();
            bool isCyclic         = cyclicGraphCheck.IsCyclic(digraph);

            Assert.True(isCyclic);
        }
Example #6
0
        public Graph <char> ReadAndBuildRoutes()
        {
            WriteInputInstructions();
            var graphBuilder = new DirectedGraphBuilder <char>();

            string routeInput;

            while ((routeInput = ReadRouteInput()) != "OK")
            {
                try
                {
                    var routeModel = ParseAndValidateRouteInput(graphBuilder, routeInput);
                    AddRoute(graphBuilder, routeModel);
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine($"Error: {ex.Message}\n");
                }
            }

            var routesGraph = graphBuilder.GetGraph();

            WriteInputSummary(routesGraph);

            return(routesGraph);
        }
        protected override void ProcessRecord()
        {
            if (!this.CheckFileExists(this.Filename))
            {
                return;
            }

            this.WriteVerbose("Loading {0} as xml", this.Filename);
            var xmldoc = SXL.XDocument.Load(this.Filename);

            var root = xmldoc.Root;
            this.WriteVerbose("Root element name ={0}", root.Name);
            if (root.Name == "directedgraph")
            {
                this.WriteVerbose("Loading as a Directed Graph");
                var dg_model = DirectedGraphBuilder.LoadFromXml(
                    this.Client,
                    xmldoc);
                this.WriteObject(dg_model);               
            }
            else if (root.Name == "orgchart")
            {
                this.WriteVerbose("Loading as an Org Chart");
                var oc = OrgChartBuilder.LoadFromXml(this.Client, xmldoc);
                this.WriteObject(oc);
            }
            else
            {
                var exc = new ArgumentException("Unknown root element for XML");
                throw exc;
            }
        }
Example #8
0
        private void draw_directed_graph(VisioAutomation.Scripting.Client client, string dg_text)
        {
            var dg_xml   = SXL.XDocument.Parse(dg_text);
            var dg_model = DirectedGraphBuilder.LoadFromXML(client, dg_xml);

            // TODO: Investigate if this this special case for Visio 2013 can be removed
            // this is a temporary fix to handle the fact that server_u.vss in Visio 2013 doesn't result in server_u.vssx
            // gettign automatically loaded

            var version = client.Application.Version;

            if (version.Major >= 15)
            {
                foreach (var drawing in dg_model)
                {
                    foreach (var shape in drawing.Shapes)
                    {
                        if (shape.StencilName == "server_u.vss")
                        {
                            shape.StencilName = "server_u.vssx";
                        }
                    }
                }
            }

            client.Draw.DirectedGraph(dg_model);
        }
        public void TestIsConnectionCyclic1()
        {
            var cyclicTest = new CyclicConnectionTest();

            var connArr = new DirectedConnection[3];

            connArr[0] = new DirectedConnection(0, 2);
            connArr[1] = new DirectedConnection(2, 3);
            connArr[2] = new DirectedConnection(3, 1);

            DirectedGraph digraph = DirectedGraphBuilder.Create(connArr, 1, 1);

            // True tests (cycle).
            Assert.IsTrue(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(0, 0)));
            Assert.IsTrue(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(1, 1)));
            Assert.IsTrue(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(2, 2)));
            Assert.IsTrue(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(3, 3)));
            Assert.IsTrue(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(2, 0)));
            Assert.IsTrue(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(3, 0)));
            Assert.IsTrue(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(1, 0)));
            Assert.IsTrue(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(3, 2)));
            Assert.IsTrue(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(1, 2)));
            Assert.IsTrue(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(1, 3)));

            // False tests (no cycle).
            Assert.IsFalse(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(0, 3)));
            Assert.IsFalse(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(0, 1)));
            Assert.IsFalse(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(2, 1)));
            Assert.IsFalse(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(3, 1)));
        }
        public void TestIsConnectionCyclic2()
        {
            var cyclicTest = new CyclicConnectionTest();

            var connArr = new DirectedConnection[8];

            connArr[0] = new DirectedConnection(0, 5);
            connArr[1] = new DirectedConnection(0, 2);
            connArr[2] = new DirectedConnection(0, 3);
            connArr[3] = new DirectedConnection(5, 4);
            connArr[4] = new DirectedConnection(4, 2);
            connArr[5] = new DirectedConnection(2, 1);
            connArr[6] = new DirectedConnection(3, 6);
            connArr[7] = new DirectedConnection(3, 2);
            Array.Sort(connArr);

            DirectedGraph digraph = DirectedGraphBuilder.Create(connArr, 1, 1);

            // True tests (cycle).
            Assert.IsTrue(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(2, 5)));
            Assert.IsTrue(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(2, 4)));
            Assert.IsTrue(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(1, 2)));
            Assert.IsTrue(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(1, 0)));
            Assert.IsTrue(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(1, 4)));
            Assert.IsTrue(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(6, 0)));

            // False tests (no cycle).
            Assert.IsFalse(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(3, 1)));
            Assert.IsFalse(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(5, 3)));
            Assert.IsFalse(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(6, 5)));
            Assert.IsFalse(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(6, 2)));
            Assert.IsFalse(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(6, 4)));
            Assert.IsFalse(cyclicTest.IsConnectionCyclic(digraph, new DirectedConnection(3, 4)));
        }
        public void NewBuilder_ReturnsEmptyBuilder()
        {
            var graph = DirectedGraphBuilder <string> .NewBuilder().CreateGraph();

            graph.Count.Should().Be(0);
            graph.Elements.Should().BeEmpty();
        }
Example #12
0
        public void ConnectThroughInput()
        {
            // Simple acyclic graph.
            var connList = new List <DirectedConnection>
            {
                new DirectedConnection(0, 3),
                new DirectedConnection(1, 3),
                new DirectedConnection(2, 3),
                new DirectedConnection(2, 4),
                new DirectedConnection(4, 1)
            };

            // Create graph.
            connList.Sort();
            var digraph = DirectedGraphBuilder.Create(connList, 3, 2);

            // Assert is acyclic.
            var cyclicGraphAnalysis = new CyclicGraphAnalysis();

            Assert.IsTrue(!cyclicGraphAnalysis.IsCyclic(digraph));

            // Depth analysis.
            GraphDepthInfo depthInfo = AcyclicGraphDepthAnalysis.CalculateNodeDepths(digraph);

            // Assertions.
            Assert.AreEqual(4, depthInfo._networkDepth);
            Assert.AreEqual(5, depthInfo._nodeDepthArr.Length);

            // Node depths.
            Assert.AreEqual(0, depthInfo._nodeDepthArr[0]);
            Assert.AreEqual(2, depthInfo._nodeDepthArr[1]);
            Assert.AreEqual(0, depthInfo._nodeDepthArr[2]);
            Assert.AreEqual(3, depthInfo._nodeDepthArr[3]);
            Assert.AreEqual(1, depthInfo._nodeDepthArr[4]);
        }
 private static DirectedGraphBuilder <string> createBuilderForAcyclicGraph()
 {
     return(DirectedGraphBuilder <string> .NewBuilder()
            .AddElement("A")
            .AddElement("B")
            .AddArrow("A", "B"));
 }
        public void SimpleAcyclic_DefinedNodes_NodeIdGap()
        {
            // Simple acyclic graph.
            var connList = new List <DirectedConnection>
            {
                new DirectedConnection(100, 103),
                new DirectedConnection(101, 103),
                new DirectedConnection(102, 103),
                new DirectedConnection(102, 104)
            };

            // Create graph.
            var digraph = DirectedGraphBuilder.Create(connList, 0, 10);

            // The gaps in the node IDs should be removed such that node IDs form a contiguous span starting from zero.
            var connListExpected = new List <DirectedConnection>
            {
                new DirectedConnection(10, 13),
                new DirectedConnection(11, 13),
                new DirectedConnection(12, 13),
                new DirectedConnection(12, 14)
            };

            CompareConnectionLists(connListExpected, digraph.ConnectionIdArrays);

            // Check the node count.
            Assert.Equal(15, digraph.TotalNodeCount);
        }
        public void EmptyGraph_ReturnsEmptyGraph()
        {
            var graph = DirectedGraphBuilder <string> .EmptyGraph();

            graph.Count.Should().Be(0);
            graph.Elements.Should().BeEmpty();
        }
        public void Regression1()
        {
            // Simple acyclic graph.
            var connList = new List <DirectedConnection>
            {
                new DirectedConnection(0, 2),
                new DirectedConnection(0, 3),
                new DirectedConnection(0, 4),
                new DirectedConnection(2, 5),
                new DirectedConnection(3, 6),
                new DirectedConnection(4, 7),
                new DirectedConnection(5, 8),
                new DirectedConnection(6, 4),
                new DirectedConnection(6, 9),
                new DirectedConnection(7, 10),
                new DirectedConnection(8, 1),
                new DirectedConnection(9, 1),
                new DirectedConnection(10, 1)
            };

            // Create graph.
            connList.Sort();
            var digraph = DirectedGraphBuilder.Create(connList, 0, 0);

            // Test if cyclic.
            var  cyclicGraphAnalysis = new CyclicGraphAnalysis();
            bool isCyclic            = cyclicGraphAnalysis.IsCyclic(digraph);

            Assert.IsFalse(isCyclic);
        }
        public void AddArrow_ThrowsOnNullFrom()
        {
            var builder = DirectedGraphBuilder <string> .NewBuilder().AddElement("to");

            Action addArrowFromNullToTo = () => builder.AddArrow(null, "to");

            addArrowFromNullToTo.Should().Throw <ArgumentNullException>();
        }
        public void AddArrow_ThrowsOnMissingTo()
        {
            var builder = DirectedGraphBuilder <string> .NewBuilder().AddElement("to");

            Action addArrowFromFromToTo = () => builder.AddArrow("from", "to");

            addArrowFromFromToTo.Should().Throw <ArgumentException>();
        }
        public void AddElement_DoesNotAddDirectPredecessor()
        {
            var graph = DirectedGraphBuilder <string> .NewBuilder()
                        .AddElement("element")
                        .CreateGraph();

            graph.GetDirectPredecessorsOf("element").Should().BeEmpty();
        }
        public void AddArrow_ThrowsOnNullTo()
        {
            var builder = DirectedGraphBuilder <string> .NewBuilder().AddElement("from");

            Action addArrowFromFromToNull = () => builder.AddArrow("from", null);

            addArrowFromFromToNull.Should().Throw <ArgumentNullException>();
        }
        public void AddElement_ShouldThrowOnDuplicate()
        {
            var builder = DirectedGraphBuilder <string> .NewBuilder().AddElement("element");

            Action addDuplicateElement = () => builder.AddElement("element");

            addDuplicateElement.Should().Throw <ArgumentException>();
        }
Example #22
0
        private RouteModel ParseAndValidateRouteInput(DirectedGraphBuilder <char> graphBuilder, string routeInput)
        {
            var routeModel = routeInputParser.ParseInputRouteToModel(routeInput);

            routeValidator.ValidateRoute(routeModel, graphBuilder.GetGraph());

            return(routeModel);
        }
Example #23
0
        public void Solve_EmptyInput_ReturnsEmptyOutput()
        {
            var graph = DirectedGraphBuilder <string> .EmptyGraph();

            var solver = CoffmanGraham.SolverForArbitraryGraphs(1);

            solver.Solve(graph).Should().BeEmpty();
        }
        public void AddElement_ShouldThrowOnNull()
        {
            var builder = DirectedGraphBuilder <string> .NewBuilder();

            Action addNullElement = () => builder.AddElement(null);

            addNullElement.Should().Throw <ArgumentNullException>();
        }
        public void AddElement_SetsCorrectCount()
        {
            var graph = DirectedGraphBuilder <string> .NewBuilder()
                        .AddElement("element")
                        .CreateGraph();

            graph.Count.Should().Be(1);
        }
        public void AddElement_AddsElement()
        {
            var graph = DirectedGraphBuilder <string> .NewBuilder()
                        .AddElement("element")
                        .CreateGraph();

            graph.Elements.Should().Contain("element");
        }
        public void TestOneEdgeAugmented()
        {
            // build graph.
            var graph = new Itinero.Graphs.Graph(EdgeDataSerializer.Size);

            graph.AddVertex(0);
            graph.AddVertex(1);
            graph.AddEdge(0, 1, EdgeDataSerializer.Serialize(new EdgeData()
            {
                Distance = 100,
                Profile  = 1
            }));

            // build speed profile function.
            var speed = 100f / 3.6f;
            Func <ushort, FactorAndSpeed> getFactor = (x) =>
            {
                return(new FactorAndSpeed()
                {
                    Direction = 0,
                    SpeedFactor = 1.0f / speed,
                    Value = 1.0f / speed
                });
            };

            // convert graph.
            var directedGraph = new DirectedDynamicGraph(ContractedEdgeDataSerializer.DynamicAugmentedFixedSize);
            var algorithm     = new DirectedGraphBuilder <Weight>(graph, directedGraph, new WeightHandler(getFactor));

            algorithm.Run();

            // check result.
            Assert.IsTrue(algorithm.HasRun);
            Assert.IsTrue(algorithm.HasSucceeded);

            directedGraph.Compress();
            Assert.AreEqual(2, directedGraph.VertexCount);
            Assert.AreEqual(2, directedGraph.EdgeCount);

            // verify all edges.
            var edges = directedGraph.GetEdgeEnumerator(0);

            Assert.AreEqual(1, edges.Count());
            var data = ContractedEdgeDataSerializer.SerializeDynamicAugmented(100 * getFactor(1).Value, null, 100, 100 * getFactor(1).Value);

            Assert.AreEqual(data[0], edges.First().Data[0]);
            Assert.AreEqual(data[1], edges.First().Data[1]);
            Assert.AreEqual(data[2], edges.First().Data[2]);
            Assert.AreEqual(1, edges.First().Neighbour);

            edges = directedGraph.GetEdgeEnumerator(1);
            Assert.AreEqual(1, edges.Count());
            data = ContractedEdgeDataSerializer.SerializeDynamicAugmented(100 * getFactor(1).Value, null, 100, 100 * getFactor(1).Value);
            Assert.AreEqual(data[0], edges.First().Data[0]);
            Assert.AreEqual(data[1], edges.First().Data[1]);
            Assert.AreEqual(data[2], edges.First().Data[2]);
            Assert.AreEqual(0, edges.First().Neighbour);
        }
Example #28
0
        public void TestOneEdge()
        {
            // build graph.
            var graph = new Itinero.Graphs.Graph(EdgeDataSerializer.Size);

            graph.AddVertex(0);
            graph.AddVertex(1);
            graph.AddEdge(0, 1, EdgeDataSerializer.Serialize(new EdgeData()
            {
                Distance = 100,
                Profile  = 1
            }));

            // build speed profile function.
            var speed = 100f / 3.6f;
            Func <ushort, Factor> getFactor = (x) =>
            {
                return(new Factor()
                {
                    Direction = 0,
                    Value = 1.0f / speed
                });
            };

            // convert graph.
            var directedGraph = new DirectedMetaGraph(ContractedEdgeDataSerializer.Size,
                                                      ContractedEdgeDataSerializer.MetaSize);
            var algorithm = new DirectedGraphBuilder(graph, directedGraph, getFactor);

            algorithm.Run();

            // check result.
            Assert.IsTrue(algorithm.HasRun);
            Assert.IsTrue(algorithm.HasSucceeded);

            directedGraph.Compress();
            Assert.AreEqual(2, directedGraph.VertexCount);
            Assert.AreEqual(2, directedGraph.EdgeCount);

            // verify all edges.
            var edges = directedGraph.GetEdgeEnumerator(0);

            Assert.AreEqual(1, edges.Count);
            var data = ContractedEdgeDataSerializer.Serialize(100 * getFactor(1).Value, null);

            Assert.AreEqual(data, edges.First().Data[0]);
            Assert.AreEqual(Constants.NO_VERTEX, edges.First().MetaData[0]);
            Assert.AreEqual(1, edges.First().Neighbour);

            edges = directedGraph.GetEdgeEnumerator(1);
            Assert.AreEqual(1, edges.Count);
            data = ContractedEdgeDataSerializer.Serialize(100 * getFactor(1).Value, null);
            Assert.AreEqual(data, edges.First().Data[0]);
            Assert.AreEqual(Constants.NO_VERTEX, edges.First().MetaData[0]);
            Assert.AreEqual(0, edges.First().Neighbour);
        }
    public void Random1()
    {
        // Simple acyclic graph.
        var connList = new LightweightList <DirectedConnection>
        {
            new DirectedConnection(0, 2),
            new DirectedConnection(0, 3),
            new DirectedConnection(0, 4),
            new DirectedConnection(2, 5),
            new DirectedConnection(2, 10),
            new DirectedConnection(3, 1),
            new DirectedConnection(3, 4),
            new DirectedConnection(3, 6),
            new DirectedConnection(3, 7),
            new DirectedConnection(4, 1),
            new DirectedConnection(4, 6),
            new DirectedConnection(4, 7),
            new DirectedConnection(4, 10),
            new DirectedConnection(5, 4),
            new DirectedConnection(5, 8),
            new DirectedConnection(6, 9),
            new DirectedConnection(7, 9),
            new DirectedConnection(7, 10),
            new DirectedConnection(8, 1),
            new DirectedConnection(8, 3),
            new DirectedConnection(8, 9),
            new DirectedConnection(9, 1),
            new DirectedConnection(10, 1),
        };

        // Create graph.
        var connSpan = connList.AsSpan();

        connSpan.Sort();
        var digraph = DirectedGraphBuilder.Create(connSpan, 1, 1);

        // Depth analysis.
        GraphDepthInfo depthInfo = new AcyclicGraphDepthAnalysis().CalculateNodeDepths(digraph);

        // Assertions.
        Assert.Equal(9, depthInfo._graphDepth);
        Assert.Equal(11, depthInfo._nodeDepthArr.Length);

        // Node depths.
        Assert.Equal(0, depthInfo._nodeDepthArr[0]);
        Assert.Equal(8, depthInfo._nodeDepthArr[1]);
        Assert.Equal(1, depthInfo._nodeDepthArr[2]);
        Assert.Equal(4, depthInfo._nodeDepthArr[3]);
        Assert.Equal(5, depthInfo._nodeDepthArr[4]);
        Assert.Equal(2, depthInfo._nodeDepthArr[5]);
        Assert.Equal(6, depthInfo._nodeDepthArr[6]);
        Assert.Equal(6, depthInfo._nodeDepthArr[7]);
        Assert.Equal(3, depthInfo._nodeDepthArr[8]);
        Assert.Equal(7, depthInfo._nodeDepthArr[9]);
        Assert.Equal(7, depthInfo._nodeDepthArr[10]);
    }
 private static DirectedGraphBuilder <string> createBuilderForTriangle()
 {
     return(DirectedGraphBuilder <string> .NewBuilder()
            .AddElement("A")
            .AddElement("B")
            .AddElement("C")
            .AddArrow("A", "B")
            .AddArrow("B", "C")
            .AddArrow("C", "A"));
 }