VHRanger / CSRGraph

A tiny library for large graphs
MIT License
111 stars 17 forks source link

csrgraph can not deal with direction graph? #7

Closed wangbingnan136 closed 3 years ago

wangbingnan136 commented 3 years ago

Dear sir: I find that:

image image image image

every time I run the code: "walks=G.random_walks(walklen=5,epochs=5,return_weight=1,neighbor_weight=1)" My jupyter kernel just break down.Does csrgraph not support node2vec on directed graph?

VHRanger commented 3 years ago

Hi,

CSRGraph is supposed to deal with directed graphs just fine by default.

Could you give me a OneDrive link to data/code to investigate and reproduce your bug?

Please note that the way you are generating the CSRGraph object is suboptimal. You can generate it directly from a networkx graph with G = cg.csrgraph(G) with G being a nx.Graph or nx.DiGraph object, and you can also generate it directly from the edgelist with G = cg.read_edgelist('wiki_edgelist.txt', header=None, sep=',').

If this bug persists, I'd be happy to fix it if I can reproduce it somehow.

wangbingnan136 commented 3 years ago

你好

默认情况下,CSRGraph应该可以处理有向图。

您能否给我一个指向数据/代码的OneDrive链接以调查和重现您的错误?

请注意,生成CSRGraph对象的方式不是最佳的。您可以直接从networkx图生成它,G = cg.csrgraph(G)其中G是nx.Graph或nx.DiGraph对象,也可以直接从Edgelist生成它G = cg.read_edgelist('wiki_edgelist.txt', header=None, sep=',')

如果该错误仍然存​​在,那么如果我可以以某种方式重现它,我将很乐意修复它。

https://github.com/shenweichen/GraphEmbedding/tree/master/data/wiki I used the "Wiki_edgelist.txt" in this program.The original codes are:

import networkx as nx G=nx.read_edgelist('Wiki_edgelist.txt',create_using = nx.DiGraph(), nodetype = None, data = [('weight', int)])

and then I transformed G to a csrgraph then used the node2vec function to generate nodes embedding but failed..

VHRanger commented 3 years ago

Thanks I'll take a look and fix it by next week

VHRanger commented 3 years ago
import csrgraph as cg
import networkx as nx

G = cg.read_edgelist("Wiki_edgelist.txt")
G2 = nx.read_edgelist(
    'Wiki_edgelist.txt',
    create_using = nx.DiGraph(), nodetype = None, data = [('weight', int)])
G2 = cg.csrgraph(G2)

G.random_walks()
G2.random_walks()

G.ggvec()
G2.ggvec()

This seems to all work on my machine with your data file. Can you confirm?

wangbingnan136 commented 3 years ago

image No,it still has problem.If you run your code on linux? I use win10,I don't know if it is the problem of operating system.

wangbingnan136 commented 3 years ago

I found that it's the problem of the version of numba,when I upgrade my numba to 0.52.0,It seems no problem!Perfect work!!

VHRanger commented 3 years ago

Thanks! I'll close this issue then.

Feel free to raise any other issue you run into