mardi 4 janvier 2022

How to create a random graph in networkx from an existing list

Using Networkx to generate a connected graph from an existing list.

Requires:

  1. Graph generated must connected but it is not required to be fully connected.

  2. The graph must be generated from the existing list.

  3. It is better to use existing networkx functions.

Examples with pictures

[9, 5, 7, 4, 2, 0, 8, 4, 0, 0, 0, 0] is the list I have used to generate graphs, and it is required to be able to select the nodes according to the given length Generate graph

enter image description here

There is only one requirement for adding edges: the generated graph must be a connected graph




Aucun commentaire:

Enregistrer un commentaire