I am new to Julia (moving from Python). I am trying to generate a bipartite weighted network from a data frame. The data frame contains the “edgelist” (i.e., a column for bottom nodes, and a column for top nodes), and a column for the weights of the edge. I found the GraphDataFrameBridge package that creates a network from two columns of the data frame, but it creates a unipartite network, and it is not clear how to import the weights. Any suggestions?
If you have an edgelist representing a bipartite network (and you’ve verified that the graph represented by those edges is bipartite), I don’t know why GraphDataFrameBridge would be creating something that’s unipartite. Do you have a MWE you can share?
Thank you very much,
I was able to decompose the problem. Now I can import the edgelist as a bipartite network. The problem was that (if I understand correctly) GraphDataFrameBridge accepts only nodes’ labels of the same type. I initially had top nodes’ labels as “Floats” and bottom nodes as “Strings” and when I converted to the same type, some top and bottom nodes turned out to have the same label.
However, I still have 2 issues:
a) (even if is_bipartite(mg) now gives true), when I try to export the adjacency matrix from the example below, I still obtain a 7X7 unweighted matrix instead of a 4X3 weighted matrix.
b) I cannot figure out how to create a list of correspondence between the indexes assigned by MetaGraph and the labels of the original nodes. Something like:
Don’t use adjacency_matrix. Use weights. You’re getting a 7x7 because you have 7 distinct vertex labels (i, j, k, z, 1, 2, 3). Adjacency matrices are square.
Thank you. I tried weights(mg) but I got the following error in the example above:
MethodError: objects of type Array{Float64,1} are not callable
Use square brackets for indexing an Array.
Any suggestion on how I can output the nXm weighted matrix?
Regarding the second issue, I found the graft.jl that seems to produce the vertex table I was looking for (although it does not seem to be supported anymore). Basically I was wondering if it is possible to output the vertexid and the label of the id. My labels are i,j,k,z,1,2,3 but they are indexed and I do not know what node gets what index. For example, when I output the adjacency matrix I do not know whether the first row is for i,j,…etc. I need this information to merge the output of the network analysis with other variables. Hope I was able to explain myself.