From e338058710cb1bfd4478d0f4865a2d106aa1cda1 Mon Sep 17 00:00:00 2001
From: Paul Nitzke <14367-paulenit@users.noreply.git.rwth-aachen.de>
Date: Tue, 21 Jun 2022 23:34:01 +0200
Subject: [PATCH] Complete documentation for MatrixMarketWriter

* Also rename internal parameters to follow C# naming conventions
---
 .../Convert/MatrixMarketWriter.cs             | 44 ++++++++++++++-----
 1 file changed, 33 insertions(+), 11 deletions(-)

diff --git a/src/SparseTransform/Convert/MatrixMarketWriter.cs b/src/SparseTransform/Convert/MatrixMarketWriter.cs
index 1a110af..06bbc5f 100644
--- a/src/SparseTransform/Convert/MatrixMarketWriter.cs
+++ b/src/SparseTransform/Convert/MatrixMarketWriter.cs
@@ -2,22 +2,44 @@
 
 namespace SparseTransform.Convert
 {
+    /// <summary>
+    /// Provides an IWriter implementation that outputs a MatrixMarket string.
+    /// Supports output of both the seed matrix and compressed matrix.
+    /// </summary>
     class MatrixMarketWriter : IWriter
     {
-        private bool seed;
-        private DoubleMatrix inputMatrix;
+        /// <summary>
+        /// If true, write (only) the seed matrix
+        /// </summary>
+        private bool _seed;
+
+        /// <summary>
+        /// Input matrix that was read in using an IReader implementation.
+        /// Used for computing the compressed matrix.
+        /// </summary>
+        private DoubleMatrix _inputMatrix;
 
+        /// <summary>
+        /// Construct a new MatrixMarketWriter.
+        /// </summary>
+        /// <param name="seed">if true, output seed matrix</param>
+        /// <param name="inputMatrix">input matrix</param>
         public MatrixMarketWriter(bool seed, DoubleMatrix inputMatrix)
         {
-            this.inputMatrix = inputMatrix;
-            this.seed = seed;
+            this._inputMatrix = inputMatrix;
+            this._seed = seed;
         }
 
-
+        /// <summary>
+        /// Transforms the <c>graph</c> to a MatrixMarket string.
+        /// If seed flag was set in constructor, the seed matrix is written.
+        /// </summary>
+        /// <param name="graph">IGraph implementation to transform</param>
+        /// <returns>MatrixMarket string</returns>
         public string Write(IGraph graph)
         {
-            IntegerMatrix? seedMatrix = graph.ToSeedMatrix(inputMatrix.RowCount);
-            if (seed)
+            IntegerMatrix? seedMatrix = graph.ToSeedMatrix(_inputMatrix.RowCount);
+            if (_seed)
             {
                 // ziemlich wilder ausdruck, wa? Liefert die seed matrix aus einem AdjacencyGraph oder BipartiteGraph. (je nachdem was IGraph ist)
                 
@@ -29,18 +51,18 @@ namespace SparseTransform.Convert
             }
             else
             {
-                if (seedMatrix is IntegerMatrix && inputMatrix is DoubleMatrix && seedMatrix.RowCount != 0)
+                if (seedMatrix is IntegerMatrix && _inputMatrix is DoubleMatrix && seedMatrix.RowCount != 0)
                 {
-                    return CalculateCompressedMatrix(inputMatrix, seedMatrix).ToMatrixMarketString();
+                    return CalculateCompressedMatrix(_inputMatrix, seedMatrix).ToMatrixMarketString();
                 }
                 return "null";
             }
         }
 
         /// <summary>
-        /// todo
+        /// Calculate the compressed matrix from the input and seed matrix.
+        /// The formula is A*S = B where A is the input and B the compressed matrix.
         /// </summary>
-        /// <exception cref="NotImplementedException"></exception>
         private DoubleMatrix CalculateCompressedMatrix(DoubleMatrix inputMatrix, IntegerMatrix seedMatrix)
         {
             return inputMatrix.Multiply(seedMatrix);
-- 
GitLab