I have two graph objects made from scratch with Networkx (Python 3.8). To help understanding the situation this is a summary snippet:
G = nx.Graph()
Z = nx.Graph()
#some work here to get data for nodes and edges
G.add_nodes_from([(data["id"], {"origin": data["origin"], "text": data["text"]})])
#some other work in order to hash data for improved nodes privacy
G.add_edge(h.hexdigest(), data["x"])
Z.add_edge(h.hexdigest(), data["x"], weight=polarity) #here polarity is a simple double value
Now, the problem is that I want to export those objects in order to do some work with RStudio and the package igraph. Until now I've tried the following things (without any luck):
- Export to a straightforward adjacency list (but in RStudio I get an error, something related to the fact that it expects a square matrix, I don't remember well)
- Export to an edge list (but I get another type of error, it seems that i cannot use the weight representation)
- Use a naive approach, export in gml format, then install python-igraph, read the gml file with the function
Read_Adjacency()and then re-export with the functionWrite_Adjacency()(hoping that with this intermediate step it somehow make the format understandable by igraph) - I tried the solutions proposed here but also this time without success
How can I do ?
This is the code I use in RStudio:
ADJACENCY=read.csv("myadjlist.csv",header=FALSE,row.names=NULL,sep=";")
ADJACENCY=as.matrix(ADJACENCY)
#then we create the graph
G=graph_from_adjacency_matrix(ADJACENCY, mode="undirected")
And the error:
Error in graph.adjacency.dense(adjmatrix, mode = mode, weighted = weighted, : At structure_generators.c:274 : Non-square matrix, Non-square matrix
This is my adjacency list:
ADJACENCYis actually not an adjacency matrix. Please, share it withdputso we can check it. - nicola820976985387313;d54fd34cbddc270cafac961fa721b4406cc6de97;1c0e32c2bebad24ad7a06350a909788643ed13aa;ec13d5dd8f9e011e3114bd23404fe1a50da875aa. What is supposed to mean? - nicolanx.write_adjlist(G, "my csv"). So I expect the output to be an adj list. My interpretation of that line is that node820976985387313is connected withd54fd34cbddc270cafac961fa721b4406cc6de97and so on until the newline character is reached - docdev