Skip to content
Snippets Groups Projects
Commit 1e9a20d9 authored by Paul Nitzke's avatar Paul Nitzke
Browse files

Fix: Do not add diagonal to AdjacencyMatrix

* This check was incorrectly implemented in MatrixMarketReader and was
  now moved to AdjacencyGraph's AddElement
* It remains unclear what should happen if we pass a diagonal matrix
  such as bcsstm01 to the algorithm. Our current implementation produced
  empty compressed and seed matrices which feels incorrect.

  I feel like the seed matrix should in this case be the identity matrix
  but I am unsure if it is as simple as providing the seed matrix if the
  graph is empty (only diagonal elements). Because if there is one
  non-diagonal element the diagonal would nonetheless be neglected in
  calculating the seed matrix.
parent 1a51c78e
Branches
No related tags found
1 merge request!22Non-minor rewrites of the design spec to accomodate new requirements
......@@ -126,8 +126,8 @@ namespace SparseTransform.Convert
string[] values;
int lineCount = getFirstDataLine(matrix);
matrix[lineCount] = "% " + matrix[lineCount];
// try
// {
try
{
foreach (String line in matrix)
{
if (line != "")
......@@ -142,19 +142,15 @@ namespace SparseTransform.Convert
}
int xCoordinate = Int32.Parse(values[0]);
int yCoordinate = Int32.Parse(values[1]);
// if (xCoordinate != yCoordinate)
// {
processor(xCoordinate, yCoordinate, Double.Parse(values[2]));
// graph.AddEdge(xCoordinate, yCoordinate);
// }
processor(xCoordinate, yCoordinate, Double.Parse(values[2]));
}
}
}
// }
// catch (Exception e)
// {
// throw e;
// }
}
catch (Exception e)
{
throw e;
}
}
......
......@@ -68,15 +68,18 @@ namespace DataStructures
public void AddEdge(int i, int j)
{
GraphNode iNode = AddNode(i);
GraphNode jNode = AddNode(j);
iNode.AddEdge(jNode);
jNode.AddEdge(iNode);
// Update degree
if (iNode.Degree > MaxDegree)
_maxDegree = iNode.Degree;
if (jNode.Degree > MaxDegree)
_maxDegree = jNode.Degree;
if(i != j)
{
GraphNode iNode = AddNode(i);
GraphNode jNode = AddNode(j);
iNode.AddEdge(jNode);
jNode.AddEdge(iNode);
// Update degree
if (iNode.Degree > MaxDegree)
_maxDegree = iNode.Degree;
if (jNode.Degree > MaxDegree)
_maxDegree = jNode.Degree;
}
}
/// <summary>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment