Matrix, Graph, Data Science, Artificial Intelligence, Linear Algebra.
and convert it to matrix form: import networkx as nx import numpy as np G = nx.Graph() G.add_nodes_from( [("A", "B"), ("B", "C"), ("A", "C"), ("B", "D")] ) adj_mat = nx.to_adjacency_matrix(G) # This is what adj_mat looks like adj_mat # output: array([[0., 1., 1., 0.], [1., 0., 1., 1.], [1., 1., 0.,