lundi 19 février 2018

assciate for each vertice a random vector and a random vector using netwkorx random graph generation

l'm newbie to random graph generation in python.

l discovered that networks library allows to do that.

However, l would like to generate random graphs where we associate for each vertice a random color and a random vector of size 200.

Here is what l tried to make the graph

import sys

import matplotlib.pyplot as plt
import networkx as nx


G = nx.grid_2d_graph(7, 7)  


nx.write_adjlist(G, sys.stdout.buffer)  # write adjacency list to screen
# write edgelist to grid.edgelist

nx. write_edgelist(G, path="grid.edgelist", delimiter=":")

# read edgelist from grid.edgelist

H = nx.read_edgelist(path="grid.edgelist", delimiter=":")

nx.draw(H)
plt.show()

However, all the vertices have the same color and don't have any random vector.

What l would like to get is from the generated graph : we associate a random color for each vertice and a random vector.

Hoc can l do that ?

Here is the generated graph :

enter image description here

Thank you




Aucun commentaire:

Enregistrer un commentaire