Skip to content
Snippets Groups Projects
Commit 0f5ffbb3 authored by Dennis Wobbe's avatar Dennis Wobbe :speech_balloon:
Browse files

Adding documentation and minor changes in MatrixMarketReader class

parent e6c1063a
Branches
No related tags found
1 merge request!21Near final implementation of Convert package + documentation
......@@ -21,7 +21,7 @@ namespace SparseTransform.Convert
/// <summary>
/// auxiliary method for transforming <c>matrix</c> in a bipartit graph
/// </summary>
/// <param name="matrix"></param>
/// <param name="matrix">input matrix string</param>
/// <returns></returns>
BipartiteGraph ReadBipartite(String matrix);
......
......@@ -38,7 +38,11 @@ namespace SparseTransform.Convert
}
}
/// <summary>
/// checks with ANTLR4.0 whether the header is a valid instance. The header grammar can be found in the file MMFHeader.g4
/// </summary>
/// <param name="header">header of the MMF-input</param>
/// <returns></returns>
private bool checkHeader(string header)
{
AntlrInputStream stream = new AntlrInputStream(header);
......@@ -52,6 +56,11 @@ namespace SparseTransform.Convert
}
/// <summary>
/// checks whether the comment-section is valid.
/// </summary>
/// <param name="lines">entire input split by newlines</param>
/// <exception cref="Exception"></exception>
private void checkComments(string[] lines)
{
bool leftComments = false;
......@@ -79,6 +88,13 @@ namespace SparseTransform.Convert
}
/// <summary>
/// creates a graph from the data-section of the MMF-input and meanwhile checks whether the data-section is valid
/// </summary>
/// <param name="matrix"></param>
/// <param name="graph"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public IGraph ReadGraph(string[] matrix, IGraph graph)
{
string[] values;
......@@ -101,7 +117,10 @@ namespace SparseTransform.Convert
int xCoordinate = Int32.Parse(values[0]);
int yCoordinate = Int32.Parse(values[1]);
String value = values[2];
addEdge(xCoordinate, yCoordinate, graph);
if (xCoordinate != yCoordinate)
{
graph.AddEdge(xCoordinate, yCoordinate);
}
}
}
}
......@@ -113,14 +132,13 @@ namespace SparseTransform.Convert
}
}
private void addEdge(int xCoordinate, int yCoordinate, IGraph g)
{
if (xCoordinate != yCoordinate)
{
g.AddEdge(xCoordinate, yCoordinate);
}
}
/// <summary>
/// computes the first data-line in the MMF-input
/// </summary>
/// <param name="lines"></param>
/// <returns></returns>
private int getFirstDataLine(String[] lines)
{
int firstDataLine = 0;
......
......@@ -25,6 +25,7 @@ namespace SparseTransform.Convert
{
if (seed)
{
// ziemlich wilder ausdruck, wa? Liefert die seed matrix aus einem AdjacencyGraph oder BipartiteGraph. (je nachdem was IGraph ist)
IntegerMatrix matrix = graph.ToSeedMatrix(graph is AdjacencyGraph ? ((AdjacencyGraph)graph).GetNodeCount() : ((BipartiteGraph)graph).GetRightNodeCount());
if (matrix.RowCount != 0)
{
......@@ -38,10 +39,13 @@ namespace SparseTransform.Convert
}
}
/// <summary>
/// todo
/// </summary>
/// <exception cref="NotImplementedException"></exception>
private void CalculateCompressedMatrix()
{
throw new NotImplementedException();
}
}
}
\ No newline at end of file
......@@ -12,6 +12,13 @@ namespace Transform.Convert
{
internal class VisitorHeader : MMFHeaderBaseVisitor<bool>
{
/// <summary>
/// visits the AST and helps to decide whether the input matrix is symmetric
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public override bool VisitHeader([NotNull] MMFHeaderParser.HeaderContext context)
{
if ((context.format().choice1() is null || context.format().choice1().GENERAL() is null)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment