def connect(self, whom, direction="<STR_LIT:to>"):
<EOL>if direction not in ["<STR_LIT:to>", "<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>raise ValueError(<EOL>"<STR_LIT>".format(direction)<EOL>)<EOL><DEDENT>whom = self.flatten([whom])<EOL>new_vectors = []<EOL>if direction in ["<STR_LIT:to>", "<STR_LIT>"]:<EOL><INDENT>already_connected_to = self.flatten(<EOL>[self.is_connected(direction="<STR_LIT:to>", whom=whom)]<EOL>)<EOL>for node, connected in zip(whom, already_connected_to):<EOL><INDENT>if connected:<EOL><INDENT>print(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(self, node)<EOL>)<EOL><DEDENT>else:<EOL><INDENT>new_vectors.append(Vector(origin=self, destination=node))<EOL><DEDENT><DEDENT><DEDENT>if direction in ["<STR_LIT>", "<STR_LIT>"]:<EOL><INDENT>already_connected_from = self.flatten(<EOL>[self.is_connected(direction="<STR_LIT>", whom=whom)]<EOL>)<EOL>for node, connected in zip(whom, already_connected_from):<EOL><INDENT>if connected:<EOL><INDENT>print(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>".format(self, node)<EOL>)<EOL><DEDENT>else:<EOL><INDENT>new_vectors.append(Vector(origin=node, destination=self))<EOL><DEDENT><DEDENT><DEDENT>return new_vectors<EOL>
Create a vector from self to/from whom.

        Return a list of newly created vector between the node and whom.
        ``whom`` can be a specific node or a (nested) list of nodes. Nodes can
        only connect with nodes in the same network. In addition nodes cannot
        connect with themselves or with Sources. ``direction`` specifies the
        direction of the connection it can be "to" (node -> whom), "from" (whom
        -> node) or both (node <-> whom). The default is "to".

        Whom may be a (nested) list of nodes.

        Will raise an error if:
            1. whom is not a node or list of nodes
            2. whom is/contains a source if direction is to or both
            3. whom is/contains self
            4. whom is/contains a node in a different network

        If self is already connected to/from whom a Warning
        is raised and nothing happens.

        This method returns a list of the vectors created
        (even if there is only one).