Returns the edge connecting the nodes with the specified indices if such an edge exists.

        Arguments:
            source_index (int): The index of one of the endpoints of queried edge.
            target_index (int): The index of the other endpoint of the queried edge.

        Returns:
            The edge connecting the nodes with the specified indices
            or `None` if no such node exists.

def get_edge_by_index(self, source_index: int, target_index: int) -> Optional[Edge]:
        """
        Returns the edge connecting the nodes with the specified indices if such an edge exists.

        Arguments:
            source_index (int): The index of one of the endpoints of queried edge.
            target_index (int): The index of the other endpoint of the queried edge.

        Returns:
            The edge connecting the nodes with the specified indices
            or `None` if no such node exists.
        """
        edge = self._edges.get((source_index, target_index))
        if edge is not None:
            return edge
        return self._edges.get((target_index, source_index))