List of all classes, functions and methods in python-igraph
class UniqueIdGenerator:
A dictionary-like class that can be used to assign unique IDs to names (say, vertex names).
Usage:
>>> gen = UniqueIdGenerator() >>> gen["A"] 0 >>> gen["B"] 1 >>> gen["C"] 2 >>> gen["A"] # Retrieving already existing ID 0 >>> gen.add("D") # Synonym of gen["D"] 3 >>> len(gen) # Number of already used IDs 4 >>> "C" in gen True >>> "E" in gen False
Method | __init__ |
No summary |
Method | __contains__ |
Checks whether `item` already has an ID or not. |
Method | __getitem__ |
Retrieves the ID corresponding to `item`. Generates a new ID for `item` if it is the first time we request an ID for it. |
Method | __setitem__ |
Overrides the ID for `item`. |
Method | __len__ |
"Returns the number of items |
Method | reverse_dict |
Returns the reverse mapping, i.e., the one that maps from generated IDs to their corresponding objects |
Method | values |
No summary |
Instance Variable | _generator |
Undocumented |
Instance Variable | _ids |
Undocumented |
Creates a new unique ID generator. `id_generator` specifies how do we assign new IDs to elements that do not have an ID yet. If it is `None`, elements will be assigned integer identifiers starting from 0. If it is an integer, elements will be assigned identifiers starting from the given integer. If it is an iterator or generator, its `next` method will be called every time a new ID is needed.
Retrieves the ID corresponding to `item`. Generates a new ID for `item` if it is the first time we request an ID for it.