ngraph.matrix
Module to transform ngraph.graph into matrix representation.
Note: This library is not supposed to be used for large graphs. It is only a demo for those who are interested in how certain graph matrix looks like.
Currently supported matrices:
- degree - diagonal matrix with node degree on the diagonal
- adjacency - matrix with (i, j) = 1 if node i is connected to j.
- laplacian -
degree - adjacency
matrix.
usage
E.g. let's comupte degree, adjacency and laplacian matrices for a complete graph K5 (five nodes, each connected with each other):
var create = ;var getMatrix = ;var graph = createcomplete5;;;;{console;for var i = 0; i < dshape0; ++ivar str = '';for var j = 0; j < dshape1 ; ++jstr += d + ' ';console;}
The output will be:
degree
4 0 0 0 0
0 4 0 0 0
0 0 4 0 0
0 0 0 4 0
0 0 0 0 4
adjacency
0 1 1 1 1
1 0 1 1 1
1 1 0 1 1
1 1 1 0 1
1 1 1 1 0
laplacian
4 -1 -1 -1 -1
-1 4 -1 -1 -1
-1 -1 4 -1 -1
-1 -1 -1 4 -1
-1 -1 -1 -1 4
install
With npm do:
npm install ngraph.matrix
license
MIT