Swelling and collapse of polymer networks in contact with polymer melts and solutions