Skip to content

adjacency_matrix

AdjacencyMatrix

Bases: NKAlgorithm

An algorithm to calculate the adjacency matrix of a graph using networkit.

The adjacency matrix is a square 2D NumPy array of shape (nodes_number, nodes_number) that represents the connections between nodes in a graph. Each entry (i, j) in the matrix is a boolean value: - 1 indicates there is an edge from node i to node j. - 0 indicates no edge exists from node i to node j.

For example

If there are 3 nodes and edges connecting: - Node 0 to Node 1, with weight 1 - Node 1 to Node 2, with weight 5 - Node 2 to Node 0, with weight 3

The adjacency matrix would look like this

[[0, 1, 0] [0, 0, 5] [3, 0, 0]]

run()

Compute the adjacency matrix of the graph.

Returns:

Type Description
ndarray

np.ndarray[N, N]: Adjacency matrix of the graph.