Giving unique IDs to all nodes?

前端 未结 4 997
小蘑菇
小蘑菇 2021-01-26 18:54

I am making a class in Python that relates a lot of nodes and edges together. I also have other operations that can take two separate objects and merge them into a single object

4条回答
  •  花落未央
    2021-01-26 19:38

    If you just need a unique identifier, the built-in Python id() function would do it:

    Return the “identity” of an object. This is an integer (or long integer) which is guaranteed to be unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes may have the same id() value.

提交回复
热议问题