@thi.ng/adjacency
Version:
Sparse & bitwise adjacency matrices, lists and selected traversal algorithms for directed & undirected graphs
68 lines • 2.57 kB
TypeScript
import { CSR } from "@thi.ng/sparse/csr";
import type { DegreeType, Edge, IGraph } from "./api.js";
export declare class AdjacencyMatrix extends CSR implements IGraph<number> {
undirected: boolean;
constructor(n: number, data: number[], rows: number[], cols: number[], undirected?: boolean);
edges(): Generator<Edge, void, unknown>;
addEdge(from: number, to: number): boolean;
removeEdge(from: number, to: number): boolean;
hasEdge(from: number, to: number): boolean;
hasVertex(id: number): boolean;
numEdges(): number;
numVertices(): number;
degree(id: number, type?: DegreeType): number;
neighbors(id: number): number[];
invert(): AdjacencyMatrix;
/**
* Returns a diagonal sparse matrix
* [`CSR`](https://docs.thi.ng/umbrella/sparse/classes/CSR.html) containing
* information about the degree of each vertex, i.e. the number of edges
* attached to each vertex.
*
* @remarks
* Reference: https://en.wikipedia.org/wiki/Degree_matrix
*
* @param deg - degree type
*/
degreeMat(deg?: DegreeType): CSR;
/**
* Returns this graph's Laplacian matrix: `L = D - A` Where `D` is the
* degree matrix and `A` this adjacency matrix.
*
* @remarks
* References:
*
* - https://en.wikipedia.org/wiki/Laplacian_matrix
* - https://en.wikipedia.org/wiki/Discrete_Laplace_operator
*
* @param deg - degree type for {@link AdjacencyMatrix.degreeMat}
*/
laplacianMat(deg?: CSR): CSR;
normalizedLaplacian(deg?: CSR): CSR;
/**
* Computes: `I - nA + n^2 * (D - I)`, where `I` is the identity matrix,
* `A` the adjacency matrix, `D` the degree matrix, and `n` is a
* (complex-valued) number.
*
* @remarks
* See {@link AdjacencyMatrix.degreeMat}.
*
* @param n - scale factor
* @param deg - degree matrix
*/
deformedLaplacian(n: number, deg?: CSR): CSR;
toDot(ids?: string[]): string;
}
/**
* Creates an adjacency matrix backed by a sparse
* [`CSR`](https://docs.thi.ng/umbrella/sparse/classes/CSR.html) matrix,
* optionally initialize with given edge pairs. Each edge is a `[src, dest]`
* tuple. If `undirected` is true (default: false), creates symmetrical edges
* (i.e. undirected graph).
*
* @param n - max number of vertices
* @param edges - edge pairs
* @param undirected - true, if undirected
*/
export declare const defAdjMatrix: (n: number, edges?: Iterable<Edge>, undirected?: boolean) => AdjacencyMatrix;
//# sourceMappingURL=sparse.d.ts.map