Exemple #1
0
        public void JustNodes()
        {
            var dot = DotGraphBuilder.DirectedGraph("NoEdges")
                      .AddNode("n1")
                      .AddNode("n2")
                      .Build();

            AssertAreSame("digraph NoEdges { n1; n2 }", dot);
        }
Exemple #2
0
        public void JustNodesWithAttributes()
        {
            var dot = DotGraphBuilder.DirectedGraph("NoEdges")
                      .AddNode("n1").With(c => c.Color("black").Shape(NodeShape.Box))
                      .AddNode("n2").With(c => c.Shape(NodeShape.Ellipse).FontSize(12).Label("node №2"))
                      .Build();

            AssertAreSame(@"digraph NoEdges { 
n1 [color=black; shape=box]; n2 [fontsize=12; label=""node №2""; shape=ellipse] }", dot);
        }
Exemple #3
0
        public void JustEdges()
        {
            var dot =
                DotGraphBuilder
                .DirectedGraph("G")
                .AddEdge("a", "b")
                .AddEdge("a", "x")
                .Build();

            AssertAreSame("digraph G { a -> b; a -> x }", dot);
        }
        static void Main(string[] args)
        {
            var dot =
                DotGraphBuilder.DirectedGraph("CommentParser")
                .AddNode("START").With(a => a.Shape(NodeShape.Ellipse).Color("green"))
                .AddNode("comment").With(a => a.Shape(NodeShape.Box))
                .AddEdge("START", "slash").With(a => a.Label("'/'"))
                .AddEdge("slash", "comment").With(a => a.Label("'/'"))
                .AddEdge("comment", "comment").With(a => a.Label("other chars"))
                .AddEdge("comment", "START").With(a => a.Label("'\\\\n'"))
                .Build();

            Console.WriteLine(dot);
            ShowRenderedGraph(dot);
        }
Exemple #5
0
        public void NamesAreEscaped()
        {
            // Используйте готовый код Graph, DotFormatWriter, чтобы пройти этот тест "за бесплатно"
            var dot = DotGraphBuilder.DirectedGraph("my graph")
                      .AddNode("42 is the answer").With(a => a.Color("#00ff00"))
                      .AddNode("-3.14")
                      .AddNode("\"quotes\"")
                      .AddEdge("3", "abc").With(a => a.Label("long text"))
                      .AddEdge("3x", "a b c").With(a => a.Label("1.234"))
                      .Build();

            AssertAreSame(@"digraph ""my graph"" {
""42 is the answer"" [color=""#00ff00""];
-3.14;
""\""quotes\"""";
3 -> abc [label=""long text""];
""3x"" -> ""a b c"" [label=1.234]
}", dot);
        }
Exemple #6
0
        public void EmptyDirecterGraph()
        {
            var dot = DotGraphBuilder.DirectedGraph("EmptyGraph").Build();

            AssertAreSame("digraph EmptyGraph { }", dot);
        }