Skip to content

.mtx to .npz #1

@CunyangWei

Description

@CunyangWei

I found that the method you provided for downloading the dataset no longer seems to be available. I'm curious whether using my own data and converting it to the .npz format required by FlashSparse in this way would be reasonable. Or do you have a better script for converting from .mtx to .npz?

Besides, FlashSparse doesn't seem to support non-square matrix?

import argparse
import numpy as np
from scipy.io import mmread
from scipy.sparse import coo_matrix

coo = mmread(xxx.mtx)
row = coo.row
col = coo.col
num_edges = coo.nnz
num_nodes_src = coo.shape[0]
num_nodes_dst = coo.shape[1]

data_dict = {
    'num_nodes_src': np.array(num_nodes_src, dtype=np.int32),
    'num_nodes_dst': np.array(num_nodes_dst, dtype=np.int32),
    'num_edges':     np.array(num_edges,     dtype=np.int32),
    'src_li':        row.astype(np.int32),
    'dst_li':        col.astype(np.int32)
}

np.savez(xxx.npz, **data_dict)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions