Weighted graph using SparseCSC julia

JuliaSparse/Metis.jl#45 is merged and included in version 1.2.0 of Metis.jl. You can now use the entries of a sparse matrix as edge weights. For example, this graph (#N are the vertices and N the weights):

#1 --- 5 --- #2
|             |
6             7
|             |
#3 --- 8 --- #4

Can be constructed and partitioned as follows:

# Construct the sparse matrix (note that we add both 1 -> 2, and 2 -> 1, etc)
I = [1, 2, 1, 3, 3, 4, 2, 4]
J = [2, 1, 3, 1, 4, 3, 4, 2]
V = [5, 5, 6, 6, 8, 8, 7, 7]

A = sparse(I, J, V)

# Construct the graph with weights
G = Metis.graph(A; weights=true)

# Do partition
Metis.partition(G, 2)
3 Likes