Esempio n. 1
0
        public void SimpleGraph()
        {
            var g   = Assets.GetSimpleGraph();
            var dot = g.GetMermaid();

            _output.WriteLine(dot);
            dot.ShouldBe(
                @"graph TD;
    a/a1;
    a/a2;
    a/a3;
    a/a4;
    a/a5;
    a/a1 -->|x/x12| a/a2;
    a/a1 -->|x/x12'| a/a2;
    a/a2 -->|x/x13| a/a3;
    a/a2 -->|x/x24| a/a4;
    a/a4 -->|x/x45| a/a5;
");
        }
Esempio n. 2
0
        public void SimpleGraph()
        {
            var g   = Assets.GetSimpleGraph();
            var dot = g.GetDot();

            _output.WriteLine(dot);
            dot.ShouldBe(
                @"digraph {
    ""a/a1"";
    ""a/a2"";
    ""a/a3"";
    ""a/a4"";
    ""a/a5"";
    ""a/a1"" -> ""a/a2"" [label=""x/x12""];
    ""a/a1"" -> ""a/a2"" [label=""x/x12'""];
    ""a/a2"" -> ""a/a3"" [label=""x/x13""];
    ""a/a2"" -> ""a/a4"" [label=""x/x24""];
    ""a/a4"" -> ""a/a5"" [label=""x/x45""];
}
");
        }
Esempio n. 3
0
        public void GetPath_ComplexQuery()
        {
            var g = Assets.GetSimpleGraph();

            _output.WriteLine(g.GetDot());

            {
                var START = 100m;

                var paths = g.GetPaths(
                    "a", "a1",
                    (sum: START, mult: START),
                    (seed, item) =>
                {
                    var d = (dynamic)item;
                    if (!d.enabled)
                    {
                        return(false, (0, 0));
                    }

                    try
                    {
                        var value = d.value;
                        return(true, (seed.sum + value, seed.mult));
                    }
                    catch (RuntimeBinderException) { }

                    try
                    {
                        var change = d.change;
                        return(true, (seed.sum, seed.mult * change));
                    }
                    catch (RuntimeBinderException) { }

                    return(false, seed);
                },