import scala.collection.immutable.IntMap
import scala.io.StdIn._

object Main extends App
{
	val (n, m) = readInts()
	
	val pathMap: IntMap[Set[Int]] = (1 to m).foldLeft[IntMap[Set[Int]]](IntMap.empty) { case (map, _) =>
		val (from, to) = readInts()
		val fromSet = map.getOrElse(from, Set.empty)
		val toSet = map.getOrElse(to, Set.empty)
		map.updated(from, fromSet + to).updated(to, toSet + from)
	}
	
	val resultMap = calc()
	
	val dists: Seq[Option[Int]] = (2 to n).map(room => resultMap.get(room))
	if(dists.exists(_.isEmpty)) println("No")
	else{
		println("Yes")
		dists.map(_.get).foreach(println)
	}
	
	
	private def calc(fromSet: Set[Int] = Set(1), distMap: Map[Int, Int] = Map(1 -> 0)): Map[Int, Int] =
	{
		val toRooms: Set[Int] = fromSet.flatMap(pathMap(_))
		if (toRooms.isEmpty || toRooms.subsetOf(distMap.keySet)) distMap
		else {
			val neverVisited = toRooms -- distMap.keySet
			val newMap = neverVisited.foldLeft(distMap) { case (tmpMap, toRoom) => tmpMap.updated(toRoom, fromSet.head)}
			calc(neverVisited, newMap)
		}
	}
	
	
	private def readInts(): (Int, Int) =
	{
		val arr = readLine().split(" ", 2).map(_.toInt)
		(arr(0), arr(1))
	}
}