I need your suggestions on how I should go about implementing an ever-increasing numbering system for my application. My application builds a graph in which its vertices are uniquely enumerated with integer. The problem I'm currently facing is the largest number representable by int or long, which poses an upper limit for the number of vertices a graph can accommodate.

All opinions are welcome here.

Thanks

有帮助吗?

解决方案

Use 64 Bit Integers (java: long, c/c++: long long).

You probably have not enough memory to store 2^63 graph nodes anyway, so you won't need more.

Remember: if every node stores its own index, using a 32 Bit index variable will require 16 gigabyte memory before you get your first collision.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top