Calculation

2 min read

graph.getNodeDegree(node, degreeType, refresh)

Get the in-degree, out-degree, degree, or all of the three kinds of degree.

Parameter

NameTypeRequiredDescription
nodestring / INodetrueNode's ID or item
degreeType'in' \ 'out' \ 'total' \ 'all'falseThe degree type. If it is assigned to 'in', returns the in-degree; 'out' returns out-degree; 'total' returns total degree; 'all' returns an object contains three kinds of the degree: { inDegree, outDegree, degree}; If it is not assigned, returns total degree as default
refreshbooleanfalseWhether to force refresh the degree for the whole graph. The default value is false. You should assign it to be true after adding edges by addItem

Usage

graph.getNodeDegree('node1', 'in');

graph.getShortestPathMatrix(cache, directed)

Get all-pairs shortest-path matrix of the graph.

Parameters

NameTypeRequiredDescription
cachebooleanfalseWhether to use the cached matrix, 'true' by default.
directedbooleanfalseWhether the graph is directed, use the value of graph.get('directed') by default.

Usage

const matrix = graph.getShortestPathMatrix();

graph.getAdjMatrix(cache, directed)

Get the adjacency matrix of the graph.

Parameters

NameTypeRequiredDescription
cachebooleanfalseWhether to use the cached matrix, 'true' by default.
directedbooleanfalseWhether the graph is directed, use the value of graph.get('directed') by default.

Usage

const matrix = graph.getAdjMatrix();