Esempio n. 1
0
        public void ToDot_InvariantCulture([NotNull, InstantHandle] Func <GraphvizGraph, string> convert)
        {
            var graph = new GraphvizGraph
            {
                Font           = new GraphvizFont("Test font", 12.5f),
                PenWidth       = 2.5,
                McLimit        = 1.5,
                NodeSeparation = 0.5,
                RankSeparation = 0.75,
                PageSize       = new GraphvizSizeF(500.5f, 425.6f),
                Quantum        = 1.5,
                Resolution     = 0.95,
                Size           = new GraphvizSizeF(350.5f, 260.4f)
            };

            const string expectedDot =
                @"fontname=""Test font""; fontsize=12.5; penwidth=2.5; mclimit=1.5; nodesep=0.5; ranksep=0.75; "
                + @"page=""500.5,425.6""; quantum=1.5; resolution=0.95; size=""350.5,260.4"";";

            using (CultureScope(EnglishCulture))
            {
                Assert.AreEqual(expectedDot, convert(graph));
            }

            using (CultureScope(FrenchCulture))
            {
                Assert.AreEqual(expectedDot, convert(graph));
            }
        }
Esempio n. 2
0
        public void Name_Throws()
        {
            var graph = new GraphvizGraph();

            // ReSharper disable once AssignNullToNotNullAttribute
            Assert.Throws <ArgumentNullException>(() => graph.Name = null);
        }
Esempio n. 3
0
 public FormatClusterEventArgs(IVertexAndEdgeListGraph <TVertex, TEdge> cluster, GraphvizGraph graphFormat)
 {
     if (cluster == null)
     {
         throw new ArgumentNullException("cluster");
     }
     this.cluster     = cluster;
     this.graphFormat = graphFormat;
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GraphvizAlgorithm{TVertex,TEdge}"/> class.
 /// </summary>
 /// <param name="graph">Graph to convert to DOT.</param>
 /// <param name="imageType">Target output image type.</param>
 /// <exception cref="T:System.ArgumentNullException"><paramref name="graph"/> is <see langword="null"/>.</exception>
 public GraphvizAlgorithm(
     [NotNull] IEdgeListGraph <TVertex, TEdge> graph,
     GraphvizImageType imageType)
 {
     ClusterCount       = 0;
     _visitedGraph      = graph ?? throw new ArgumentNullException(nameof(graph));
     ImageType          = imageType;
     GraphFormat        = new GraphvizGraph();
     CommonVertexFormat = new GraphvizVertex();
     CommonEdgeFormat   = new GraphvizEdge();
 }
Esempio n. 5
0
        public void Name()
        {
            var graph = new GraphvizGraph();

            if (graph.Name is null)
            {
                throw new InvalidOperationException($"Graph has null {nameof(GraphvizGraph.Name)}.");
            }

            graph.Name = "GraphName";
            Assert.AreSame("GraphName", graph.Name);
        }
Esempio n. 6
0
        public GraphvizAlgorithm(
            IEdgeListGraph <TVertex, TEdge> g,
            String path,
            GraphvizImageType imageType
            )
        {
            Contract.Requires(g != null);
            Contract.Requires(!String.IsNullOrEmpty(path));

            this.visitedGraph       = g;
            this.imageType          = imageType;
            this.graphFormat        = new GraphvizGraph();
            this.commonVertexFormat = new GraphvizVertex();
            this.commonEdgeFormat   = new GraphvizEdge();
        }
Esempio n. 7
0
        public void Constructor()
        {
            var graph = new GraphvizGraph();

            Assert.IsNull(graph.Comment);
            Assert.IsNull(graph.Url);
            Assert.AreEqual(GraphvizColor.White, graph.BackgroundColor);
            Assert.AreEqual(GraphvizClusterMode.Local, graph.ClusterRank);
            Assert.IsNull(graph.Font);
            Assert.AreEqual(GraphvizColor.Black, graph.FontColor);
            Assert.AreEqual(1.0, graph.PenWidth);
            Assert.IsFalse(graph.IsCentered);
            Assert.IsFalse(graph.IsCompounded);
            Assert.IsFalse(graph.IsConcentrated);
            Assert.IsFalse(graph.IsLandscape);
            Assert.IsFalse(graph.IsReMinCross);
            Assert.IsFalse(graph.IsHtmlLabel);
            Assert.IsNull(graph.Label);
            Assert.AreEqual(GraphvizLabelJustification.C, graph.LabelJustification);
            Assert.IsNotNull(graph.Layers);
            Assert.AreEqual(1.0, graph.McLimit);
            Assert.AreEqual(0.25, graph.NodeSeparation);
            Assert.AreEqual(GraphvizRankDirection.TB, graph.RankDirection);
            Assert.AreEqual(0.5, graph.RankSeparation);
            Assert.AreEqual(-1, graph.NsLimit);
            Assert.AreEqual(-1, graph.NsLimit1);
            Assert.AreEqual(GraphvizOutputMode.BreadthFirst, graph.OutputOrder);
            Assert.AreEqual(GraphvizPageDirection.BL, graph.PageDirection);
            Assert.IsNotNull(graph.PageSize);
            Assert.Zero(graph.PageSize.Width);
            Assert.Zero(graph.PageSize.Height);
            Assert.Zero(graph.Quantum);
            Assert.AreEqual(GraphvizRatioMode.Auto, graph.Ratio);
            Assert.AreEqual(0.96, graph.Resolution);
            Assert.Zero(graph.Rotate);
            Assert.AreEqual(8, graph.SamplePoints);
            Assert.AreEqual(30, graph.SearchSize);
            Assert.IsNotNull(graph.Size);
            Assert.Zero(graph.Size.Width);
            Assert.Zero(graph.Size.Height);
            Assert.AreEqual(GraphvizSplineType.Spline, graph.Splines);
            Assert.IsNull(graph.StyleSheet);
        }
 public GraphvizAlgorithm(
     IVertexAndEdgeSet <TVertex, TEdge> g,
     String path,
     GraphvizImageType imageType
     )
 {
     if (g == null)
     {
         throw new ArgumentNullException("g");
     }
     if (path == null)
     {
         throw new ArgumentNullException("path");
     }
     this.visitedGraph       = g;
     this.imageType          = imageType;
     this.graphFormat        = new GraphvizGraph();
     this.commonVertexFormat = new GraphvizVertex();
     this.commonEdgeFormat   = new GraphvizEdge();
 }
Esempio n. 9
0
 public void ToDot([NotNull] GraphvizGraph graph, [NotNull] string expectedDot)
 {
     Assert.AreEqual(expectedDot, graph.ToDot());
     Assert.AreEqual(expectedDot, graph.ToString());
 }
 public void PreProcessGraph(GraphvizGraph formatter, Solution solutionLoader)
 {
     //formatter.Ratio = GraphvizRatioMode.Fill;
     formatter.PageSize = new Size(300, 300);
 }
Esempio n. 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EdgeEventArgs{TVertex, TEdge}"/> class.
 /// </summary>
 /// <param name="clusteredGraph">Graph to format.</param>
 /// <param name="graphFormat">Graph format.</param>
 public FormatClusterEventArgs([NotNull] IVertexAndEdgeListGraph <TVertex, TEdge> clusteredGraph, [NotNull] GraphvizGraph graphFormat)
 {
     Cluster     = clusteredGraph ?? throw new ArgumentNullException(nameof(clusteredGraph));
     GraphFormat = graphFormat ?? throw new ArgumentNullException(nameof(graphFormat));
 }