Posts

Showing posts from July, 2017

The DOK Sparse Matrix Types

Mendz.Library.Matrices abstracted the sparse matrix via IDOKSparseMatrix and DOKSparseMatrixBase . Now it's time to create the classes DOKSparseMatrix and DOKConcurrentSparseMatrix. From these, the coordinates keyed and linear index keyed concrete classes will be created. If you've been waiting for it, note that Mendz.Graphs..Sparse matrices use CoordinatesKeyedConcurrentSparseMatrix , which is described in this article.

About IDOKSparseMatrix and DOKSparseMatrixBase

After much self-deliberation, I decided that the sparse matrix must be abstracted. The primary inspiration of the sparse matrix's design in Mendz.Graphs came from Wolfram where the SparseArray is shown as a collection of coordinates and their values ((0, 0) -> 1, (3, 1) -> 3, (7, 5) -> 5, ...).

Mendz.Library.Matrices

I re-organized Mendz.Library and created a separate Mendz.Library.Matrices project for the growing list of matrix-specific types and classes that started popping up while working on matrix compressions. This enhancement is big!

About Compressed Matrices

Once upon a time, there was a problem that inspired a quest. That quest created Mendz.Graphs, which is now a .Net Core class library that grew from a simple implementation of G = (V, E) in to one that also provides features to represent a graph as a list, a dense matrix, a sparse matrix and, quite recently, a compressed matrix.

ConnectionMatrix

The connection matrix is a (true, false, false)-adjacency matrix, implemented in Mendz.Graphs.Representation.Matrices namespace as the ConnectionMatrix.

Vacation Mode Off

Hope you're enjoying the summer! A new series on Mendz.Graphs starts tomorrow. Are you ready for what's coming next?

Vacation Mode On

Enjoy the summer, everyone! A new series on Mendz.Graphs starts next week. Are you ready for what's coming next? ;-)

The AdjacencyMatrix Conundrum

In Mendz.Graphs, you should find that the AdjacencyMatrix, WeightedAdjacencyMatrix and GenericAdjacencyMatrix classes are coded pretty much the same way. In fact, they are essentially coded exactly alike, with only the namespaces different. Why is this so, Mendz?

Analyzing Mendz.Graphs..Matrices

Looking at Mendz.Graphs, you can clearly see how repeatable coding patterns are celebrated. Take note, I didn't say repeating codes. I said, repeatable coding patterns. Maintenance-wise, it makes a lot of difference.

Mendz.Graphs Sparse Matrices

Mendz.Graphs provides a set of concrete sparse matrix implementations. Compared to dense matrices, sparse matrices save on memory by using only what's needed to represent the graph.

Sparse - Incidence Matrix

The incidence matrix is a rectangular matrix which entries can vary depending on whether the graph is directed or undirected, and whether the incidence matrix is oriented or not. The sparse version applies the same logic used by the dense version.

Sparse - Degree Matrix and Variations

Come to think of it, the degree matrix and its variations are really sparse. Implementing the degree matrix as a sparse matrix just makes absolute sense!

Sparse - Generic Adjacency Matrix

If there is a Mendz.Graphs..Dense.GenericAdjacencyMatrix, there should definitely be a Mendz.Graphs..Sparse.GenericAdjacencyMatrix!

Sparse - Seidel and Laplacian Adjacency Matrix

With the AdjacencyMatrixBase in place, variations of the adjacency matrix can be easily implemented.

Sparse - Adjacency Matrix

In Mendz.Graphs, representing graphs as matrices follow similar coding patterns. This is basically because they all derive from the GraphMatrixBase class. Thus, it shouldn't be surprising to see that the codes for sparse matrices look a lot like their dense matrix counterparts.

Dense vs. Sparse Matrix

In the previous series, I covered the dense matrices in Mendz.Graphs, which implement them as two-dimensional arrays T[,]. They work good, really... that is, until you start loading graphs with a very large collection of vertices and edges.

Mendz.Graphs Dense Matrices

Mendz.Graphs provides a set of concrete dense matrix implementations that can be used in operations that support two-dimensional arrays (T[,]).

Dense - Incidence Matrix

An incidence matrix shows the relationship between a vertex and an edge. An incidence matrix C is a (1, 0)-matrix, where C v,e is 1 if v and e are linked, otherwise 0. There are variations though when the graph is directed or undirected, and when the incidence matrix is oriented or not ( Wikipedia ; Wolfram ).

Dense - Degree Matrix and Variations

The degree matrix is defined as a diagonal matrix which contains information about the degree of each vertex — that is, the number of edges attached to each vertex ( Wikipedia ). The degree matrix can be easily defined using Mendz.Graphs..DenseGraphMatrixBase.

Happy 4th of July!

Celebrate Independence Day with family and friends! The Mendz.Graphs series will continue tomorrow. Have fun!

Dense - Generic Adjacency Matrix

Mendz.Graphs..Dense.AdjacencyMatrixBase makes it very easy to define (a, b, c)-adjacency matrices. So much so that I just had to create a GenericAdjacencyMatrix!