Given a dataset X and an weight matrix W a networkx graph G is given by
G = nx.Graph(W.todense())
pos = {i: list(p) for i, p in enumerate(X)}
nx.set_node_attributes(G, pos, 'pos')
The graph G has the following structure:
Can we store the graph G with the attributes weight and node position in such way to load G in Gephi and visualize the graph using these attributes?
Thank you in advance.
You have already defined nodes' attributes, so you just need to save it as a file which is acceptable in Gephi by below code:
nx.write_gexf(
G,
path,
encoding='utf-8',
prettyprint=True)
BTW, later on, you can assign any attribute to nodes or edges in .csv format and read and add them to your current graph in Gephi (this could be another option)