Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- documentclass[a4paper, twoside]{book}
- usepackage{listings}
- lstset{
- basicstyle=small,
- keywordstyle=ttfamily,
- identifierstyle=ttfamily,
- numbers=left,
- numberstyle=tiny,
- stepnumber=5,
- numbersep=5pt,
- numberfirstline=true,
- firstnumber=1,
- mathescape=true
- }
- begin{document}
- begin{lstlisting}
- g = $infty$
- for $v$ in vertices:
- s = $emptyset$
- r = ${v}$
- pred[v] = $emptyset$
- d[v] = $0$
- while not r == $emptyset$:
- x = $x in r$
- s = s $cup$ x
- r = r $setminus$ x
- for
- end{lstlisting}
- begin{lstlisting}
- step = 1
- res = new Graph()
- def BFS(v,currentLength,maxLength):
- if currentLength < maxLength:
- if not label[v]:
- label[v] = step
- step = step + 1
- for w in Neighborhood(v):
- if label[w]:
- continue
- pred[w] = v
- res.Append(v,w)
- BFS(w,currentLength + 1, maxLength)
- root = PickVertex()
- BFS(root,0,k)
- end{lstlisting}
- end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement