Skip to content

Inefficiency in overwriting of adjacency in undirected graphs #2

@eileen-kuehn

Description

@eileen-kuehn

The setting of new adjacency lists in undirected graphs is currently inefficient as first all existing edges are deleted before the new edges are inserted.

# if we know node already, clean up first
if item in self._adjacency:
for node_to in self._adjacency[item]:
del self._adjacency[node_to][item] # safe if graph undirected
for node_to in value:
self._adjacency[node_to][item] = value[node_to]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions