Ejemplo n.º 1
0
        public void DotToBifrostGraph()
        {
            DotGraph g     = DotLoader.Load(@"digraph {
            graph [bb=""0, 0, 54, 108""];
            node[label = ""\N""];
            a[height = 0.5,
                    pos = ""27,90"",
                    width = 0.75];
            b[height = 0.5,
                    pos = ""27,18"",
                    width = 0.75];
            a->b[pos = ""e,27,36.104 27,71.697 27,63.983 27,54.712 27,46.112""];
        }");
            Graph    graph = DotGraphConverter.ToGraph(g);

            Assert.Equal(2, graph.Nodes.Count);
            var nodes = graph.Nodes.ToList();

            var nodeA = nodes[0];

            Assert.Equal("a", nodeA.NodeName);
            Assert.Equal(new Point(27, 18), nodeA.Position);

            var nodeB = nodes[1];

            Assert.Equal("b", nodeB.NodeName);
            Assert.Equal(new Point(27, 90), nodeB.Position);

            List <Edge> edges = graph.Edges.ToList();

            Assert.Equal(nodeA, graph.FindNode(edges[0].StartId));
            Assert.Equal(nodeB, graph.FindNode(edges[0].EndId));
        }
Ejemplo n.º 2
0
        public void LoadDotString(string dotContent)
        {
            DotGraph dg = DotLoader.Load(dotContent);

            if (!dg.GraphAttributes.ContainsKey("bb"))
            {
                dg = GraphVizWrapper.LayoutNodes(dg);
            }
            Graph gr = DotGraphConverter.ToGraph(dg);

            adjustNodesToCenterOfViewport(gr, GraphAreaZoom.Viewport);
            LoadGraph(gr);
        }
Ejemplo n.º 3
0
        public void DotToBifrostGraphSingleNode()
        {
            DotGraph g     = DotLoader.Load(@"graph {a}");
            Graph    graph = DotGraphConverter.ToGraph(g);

            Assert.Equal(1, graph.Nodes.Count);
            var nodes = graph.Nodes.ToList();

            var nodeA = nodes[0];

            Assert.Equal("a", nodeA.Id);
            Assert.Equal("a", nodeA.NodeName);
            Assert.Equal(new Point(0, 0), nodeA.Position);
        }
Ejemplo n.º 4
0
        public void DotToBifrostGraphUseLabelForName()
        {
            DotGraph g     = DotLoader.Load(@"digraph {
            a[label=""good name""];
        }");
            Graph    graph = DotGraphConverter.ToGraph(g);

            Assert.Equal(1, graph.Nodes.Count);
            var nodes = graph.Nodes.ToList();

            var nodeA = nodes[0];

            Assert.Equal("a", nodeA.Id);
            Assert.Equal("good name", nodeA.NodeName);
        }