networkx 2.8.2 Pypi GitHub Homepage
Other Docs

The idea is that using a 2-tuple (priority, element) works for sorting, but not for dict lookup because priorities are often floating point values so round-off can mess up equality.

So, we need inequalities to look at the priority (for sorting) and equality (and hash) to look at the element to enable updates to the priority.

Unfortunately, this class can be tricky to work with if you forget that :None:None:`__lt__` compares the priority while :None:None:`__eq__` compares the element. In :None:None:`greedy_modularity_communities()` the following code is used to check that two _HeapElements differ in either element or priority:

if d_oldmax != row_max or d_oldmax.priority != row_max.priority:

If the priorities are the same, this implementation uses the element as a tiebreaker. This provides compatibility with older systems that use tuples to combine priority and elements.

This proxy class separates the heap element from its priority.

Examples

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/utils/mapped_queue.py#9
type: <class 'type'>
Commit: