snap-stanford / snap

Stanford Network Analysis Platform (SNAP) is a general purpose network analysis and graph mining library.
Other
2.17k stars 797 forks source link

CntUniqUndirEdges returns negative number #110

Closed appebyte closed 7 years ago

appebyte commented 7 years ago

I have a large undirected graph (slightly over 1 billion edges). If I try to count the unique number of edges using TSnap::CntUniqUndirEdges(Graph);, I receive the following number: -675018468.

I've looked into the source code of CntUniqUndirEdges and couldn't figure out why this is happening. I don't think it's an integer overflow. Counting the nodes works fine.

Edit: perhaps it is an integer overflow though. If I expect my edge list to be around 1.5 billion edges, does SNAP count them twice or something since this is an undirected graph, which causes this overflow? Is there any way to fix this?

I have 128 GB of RAM.

Any advice would be appreciated.

roks commented 7 years ago

This looks like an integer overflow. The edges are counted twice, so the count is divided by 2 to obtain the result. I suggest that you use 64-bit SNAP in snap-dev-64.