code: def connectSelection( self, cls = None ):
          
          # collect the selected nodes
          nodes = self.selectedNodes()
          if ( len(nodes) != 2 ):
              return None
          
          # create the connection
          con = self.addConnection(cls)
          con.setOutputNode(nodes[0])
          con.setInputNode(nodes[1])
          con.rebuild()
          
          return con
docs: Creates a connection between the currently selected \
          nodes, provided there are only 2 nodes selected.  If \
          the cls parameter is supplied then that will be the \
          class instance used when creating the connection. \
          Otherwise, the default connection class will be used.
          
          :param      cls         subclass of <XNodeConnection>
          
          :return     <XNodeConnection> || None