Fixed Compatibility Issues with NetworkX and Dictionary Iteration in Python
This commit addresses several issues in the code related to the use of outdated NetworkX methods and unsafe dictionary iteration. The changes include:
NetworkX Method Updates: Replaced nodes_iter() and edges_iter() methods from NetworkX with nodes() and edges(), respectively. This change was necessary because the former methods were removed in NetworkX 2.0 and later.
Safe Dictionary Iteration: Modified the code to prevent modification of a dictionary while iterating over it. This was achieved by creating a copy of the keys or items being iterated over before the loop starts.
Fixed Indexing of Dictionary-Keyiterator: Resolved an issue where a dictionary-keyiterator object was being indexed. This was fixed by converting the iterator to a list before indexing.
These changes have resolved the runtime errors and improved the compatibility of the code with newer versions of Python and NetworkX.
…Python
Fixed Compatibility Issues with NetworkX and Dictionary Iteration in Python
This commit addresses several issues in the code related to the use of outdated NetworkX methods and unsafe dictionary iteration. The changes include:
NetworkX Method Updates: Replaced
nodes_iter()
andedges_iter()
methods from NetworkX withnodes()
andedges()
, respectively. This change was necessary because the former methods were removed in NetworkX 2.0 and later.Safe Dictionary Iteration: Modified the code to prevent modification of a dictionary while iterating over it. This was achieved by creating a copy of the keys or items being iterated over before the loop starts.
Fixed Indexing of Dictionary-Keyiterator: Resolved an issue where a dictionary-keyiterator object was being indexed. This was fixed by converting the iterator to a list before indexing.
These changes have resolved the runtime errors and improved the compatibility of the code with newer versions of Python and NetworkX.