def validate_line_segment(self, socket_a, socket_b):
        """Raise error if segment between sockets isn't valid.

        Parameters
        ==========
        socket_a, socket_b (references to sockets)
            the sockets to be connected by a line segment.
        """
        ### there must be one, and only one output
        ### socket among the given ones, otherwise
        ### the connections can't be stablished

        output_socket_n = sum(
            1 for socket in (socket_a, socket_b) if type(socket) is OutputSocket
        )

        if output_socket_n == 0:

            raise TypeError(
                "Can't connect sockets cause both of" " them represent inputs"
            )

        elif output_socket_n == 2:

            raise TypeError(
                "Can't connect sockets cause both of" " them represent outputs"
            )

        ### there's no need to connect sockets which are
        ### already connected
        self.check_existing_segment(socket_a, socket_b)

        ### check the existence of a cycle in data flow
        ### (whether the user is trying to connect the
        ### output socket to an input socket which ends
        ### up feeding the output socket in the first
        ### place, creating a cycle)
        self.check_cyclic_flow(socket_a, socket_b)
Raise error if segment between sockets isn't valid.

        Parameters
        ==========
        socket_a, socket_b (references to sockets)
            the sockets to be connected by a line segment.
        
nodezator/graphman/socketparenthood/support.py