diff --git a/src/SparseTransform/Convert/ColoredDotWriter.cs b/src/SparseTransform/Convert/ColoredDotWriter.cs index f2e99e2ab6a376370089b37ec49ffe15d027b83b..a0a755957a2678d506ec08ec8e33286524d6da1e 100644 --- a/src/SparseTransform/Convert/ColoredDotWriter.cs +++ b/src/SparseTransform/Convert/ColoredDotWriter.cs @@ -8,16 +8,16 @@ namespace SparseTransform.Convert /// </summary> public class ColoredDotWriter : DotWriter { - private IGraph _coloredGraph; private bool _textcolor; - + private int _colorsUsed; + /// <summary> /// Constructor constructing a color-dictionary for coloring purpose. /// </summary> /// <param name="textColor">decision whether the labels should be colored or labelled.</param> public ColoredDotWriter(IGraph graph, bool textColor) { - this._coloredGraph = graph; + this._colorsUsed = graph.ColorsUsed; this._textcolor = textColor; } @@ -30,7 +30,7 @@ namespace SparseTransform.Convert public override String NodeLabel(GraphNode node, String prefix) { // This is the offset. Less colors = more distance between - int hueFactor = 255 / _coloredGraph.ColorsUsed; + int hueFactor = 255 / this._colorsUsed; // Calculate the hue. We modulo with 255 to not exceed spectrum. Then convert to float for DOT double hue = Math.Round((double)((node.Color * hueFactor) % 255) / 255, 3); @@ -41,7 +41,7 @@ namespace SparseTransform.Convert // If current node is colored, apply either text label with color or set fill color if (node.Colored) { - if (_textcolor || _coloredGraph.ColorsUsed > 255) + if (_textcolor || this._colorsUsed > 255) { label.Append($", label=\"{prefix}{node.Index}\\n color:{node.Color}\""); }