public void TinyLoopGraph()
        {
            var g   = Assets.GetTinyLoopGraph();
            var dot = g.GetMermaid();

            _output.WriteLine(dot);
            dot.ShouldBe(
                @"graph TD;
    a/a1;
    a/a2;
    a/a1 -->|x/x1| a/a2;
    a/a2 -->|z/z1| a/a1;
");
        }
Beispiel #2
0
        public void TinyLoopGraph()
        {
            var g   = Assets.GetTinyLoopGraph();
            var dot = g.GetDot();

            _output.WriteLine(dot);
            dot.ShouldBe(
                @"digraph {
    ""a/a1"";
    ""a/a2"";
    ""a/a1"" -> ""a/a2"" [label=""x/x1""];
    ""a/a2"" -> ""a/a1"" [label=""z/z1""];
}
");
        }
Beispiel #3
0
        public void GetPath_LoopNoLoop()
        {
            var g = Assets.GetTinyLoopGraph();

            _output.WriteLine(g.GetDot());

            {
                var paths = g.GetPaths("a", "a1", options: QueryOptions.Default(4)).ToArray();
                paths.Length.ShouldBe(3);
                var p0 = paths[0];
                _output.WriteLine(p0.Print());
                p0.Depth.ShouldBe(1);
                p0.Vertexes.Length.ShouldBe(1);
                p0.Edges.Length.ShouldBe(0);
                p0.Vertexes[0].Value.ShouldBe("A1");
                var p1 = paths[1];
                _output.WriteLine(p1.Print());
                p1.Depth.ShouldBe(2);
                p1.Vertexes.Length.ShouldBe(2);
                p1.Edges.Length.ShouldBe(1);
                p1.Vertexes[0].Value.ShouldBe("A1");
                p1.Edges[0].Value.ShouldBe("X1");
                p1.Vertexes[1].Value.ShouldBe("A2");
                var p2 = paths[2];
                _output.WriteLine(p2.Print());
                p2.Depth.ShouldBe(3);
                p2.Vertexes.Length.ShouldBe(3);
                p2.Edges.Length.ShouldBe(2);
                p2.Vertexes[0].Value.ShouldBe("A1");
                p2.Edges[0].Value.ShouldBe("X1");
                p2.Vertexes[1].Value.ShouldBe("A2");
                p2.Edges[1].Value.ShouldBe("Z1");
                p2.Vertexes[2].Value.ShouldBe("A1");
            }
            {
                var paths = g.GetPaths("a", "a2", options: QueryOptions.Default(2)).ToArray();
                paths.Length.ShouldBe(2);
                var p0 = paths[0];
                _output.WriteLine(p0.Print());
                p0.Depth.ShouldBe(1);
                p0.Vertexes.Length.ShouldBe(1);
                p0.Edges.Length.ShouldBe(0);
                p0.Vertexes[0].Value.ShouldBe("A2");
                var p1 = paths[1];
                _output.WriteLine(p1.Print());
                p1.Depth.ShouldBe(2);
                p1.Vertexes.Length.ShouldBe(2);
                p1.Edges.Length.ShouldBe(1);
                p1.Vertexes[0].Value.ShouldBe("A2");
                p1.Vertexes[1].Value.ShouldBe("A1");
                p1.Edges[0].Value.ShouldBe("Z1");
            }
            {
                var paths = g.GetPaths("a", "a2", options: QueryOptions.NoLoops(10)).ToArray();
                paths.Length.ShouldBe(2);
                var p0 = paths[0];
                _output.WriteLine(p0.Print());
                p0.Depth.ShouldBe(1);
                p0.Vertexes.Length.ShouldBe(1);
                p0.Edges.Length.ShouldBe(0);
                p0.Vertexes[0].Value.ShouldBe("A2");
                var p1 = paths[1];
                _output.WriteLine(p1.Print());
                p1.Depth.ShouldBe(2);
                p1.Vertexes.Length.ShouldBe(2);
                p1.Edges.Length.ShouldBe(1);
                p1.Vertexes[0].Value.ShouldBe("A2");
                p1.Vertexes[1].Value.ShouldBe("A1");
                p1.Edges[0].Value.ShouldBe("Z1");
            }
        }