Algorithm for creating adjacency matrix

631 Views Asked by At

Is it possible to create a graph ( represented in the form of Adjacency Matrix), when the number of nodes and the count of neighbors for each node is given?

1

There are 1 best solutions below

0
On

Yes, it is possible. Moreover, it is a very well known model, which produces a graph (a multigraph, to be precise) with a prescribed degree sequence (what you call in your question the count of neighbors). The only requirement is that this degree sequence is graphical, i.e., it satisfies the conditions of the Erdős–Gallai theorem, mentioned in the comment. This model is called the configuration model, and it just randomly pairs the half-edges, whose total number is $2n$, where $n$ is the number of nodes in the graph. Note that since the pairing is completely random, self-loops and multiple edges are produced. The original source for the model is this paper, but I also advise, if possible, to check out Mark Newman Network: An Introduction book for mode details.