Skip to content

Error in the __eq__() method of the GeneralGraph class #251

@Ykabrit

Description

@Ykabrit

Hello, I noticed an issue during my tests that when I compare two GeneralGraph instances, they get corrupted, more specifically the order of the nodes in self.nodes changes and no longer corresponds to the indexes in self.node_map.

Looking at the code, it seems like the problem lies in the use of the sort() method in __eq__() (see screenshot below).

Image

This method sorts the lists of nodes in-place, and returns None (which by the way makes the node lists compared here always equal).
sorted(self.nodes) and sorted(other.nodes) should probably be used as it returns the sorted list without modifying the original one.

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