{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Strict #-}
{-# LANGUAGE StrictData #-}
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import Data.Array.Unboxed
import Data.Array.ST
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Control.Monad.ST
import Data.STRef 
import Data.List
import Data.Char
import qualified Data.Map.Strict as M

convert :: Int -> Int -> VU.Vector (Int,Int) -> V.Vector [Int]
convert n m graph = V.create $ do
    v <- VM.replicate n []
    forM_ [0..m-1] $ \i -> do
        let (x,y) = graph VU.! i
        VM.modify v (y-1:) (x-1)
        VM.modify v (x-1:) (y-1)
    return v

main :: IO ()
main = do
    [n,m] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    graph' <- VU.replicateM m $ (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    let graph = convert n m graph'
    let vec = VU.create $ do
        vec <- VUM.replicate n (-1)
        VUM.write vec 0 0
        go [0] [] vec
        where go :: [Int] -> [Int] -> VUM.MVector s Int -> ST s (VUM.MVector s Int)
              go [] [] vec = return vec
              go [] ys vec = go ys [] vec
              go (n:ns) ys vec = do
                  now <- VUM.read vec n
                  ls <- newSTRef ys
                  forM_ (graph V.! n) $ \i -> do
                      b <- VUM.read vec i
                      when (b == -1) $ VUM.write vec i n >> modifySTRef ls (i:)
                  ln <- readSTRef ls
                  go ns ln vec
    putStrLn "Yes"
    VU.mapM_ print $ VU.map (+1) $ VU.tail vec