Similar function to to_scipy_sparse_matrix in Julia sparse matrices functions

Viewed 323

I would like to ask if there is equivalent function in Julia language and its functions for sparse matrices to to_scipy_sparse_matrix in networkx.

I am looking for equivalent to calling this function in eigenvector centrality algorithm.

Is there possibility to run this function as stated above, in eigenvector centrality link, in Julia to produce the same output ?

Thanks for any suggestions. I am struggling few hours with this and I am unable to make any results.

Edit:

Python version :
import networkx as nx
import scipy

G = nx.Graph()
G.add_edge(1, 2, w=1.0 )
G.add_edge(1, 3, w=0.5 )
G.add_edge(2, 3, w=2.5 )

M = nx.to_scipy_sparse_matrix(G, nodelist=list(G), weight='w',dtype=float)

print(M)

Output:
(0, 1)  1.0
(0, 2)  0.5
(1, 0)  1.0
(1, 2)  2.5
(2, 0)  0.5
(2, 1)  2.5

Julia version:
using Graphs

g1 = Graphs.graph(Graphs.ExVertex[], Graphs.ExEdge{Graphs.ExVertex}[],     is_directed=false)
d = "dist"

v1 = add_vertex!(g1, "a")
v2 = add_vertex!(g1, "b")
v3 = add_vertex!(g1, "c")

e12 = add_edge!(g1, v1, v2)
e12.attributes[d]=1.0

e13 = add_edge!(g1, v1, v3)
e13.attributes[d]=0.5

e23 = add_edge!(g1, v2, v3)
e23.attributes[d]=2.5
1 Answers
Related