summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYigit Sever2020-11-15 05:11:46 +0300
committerYigit Sever2020-11-15 05:11:46 +0300
commitfe90000730c6fc0d41f32e64a62c8c4209921856 (patch)
treed0aafbbaf0523d55fb374e273331b645305bf31b
parent2658ca84e4a0b847ee705e0aee393ef88eba10ee (diff)
downloadhw2-fe90000730c6fc0d41f32e64a62c8c4209921856.tar.gz
hw2-fe90000730c6fc0d41f32e64a62c8c4209921856.tar.bz2
hw2-fe90000730c6fc0d41f32e64a62c8c4209921856.zip
Type the draft of the answer to question 2
-rw-r--r--main.pdfbin182748 -> 199456 bytes
-rw-r--r--main.tex36
-rw-r--r--structure.tex3
3 files changed, 38 insertions, 1 deletions
diff --git a/main.pdf b/main.pdf
index 9427911..6fc1345 100644
--- a/main.pdf
+++ b/main.pdf
Binary files differ
diff --git a/main.tex b/main.tex
index da46b2a..ceb8e92 100644
--- a/main.tex
+++ b/main.tex
@@ -22,6 +22,8 @@
22\author{Yiğit Sever} 22\author{Yiğit Sever}
23\date{\today} 23\date{\today}
24 24
25\addbibresource{mylib.bib}
26
25%---------------------------------------------------------------------------------------- 27%----------------------------------------------------------------------------------------
26 28
27\begin{document} 29\begin{document}
@@ -80,8 +82,40 @@ A modified graph traversal using either BFS or DFS (since a node can be discover
80 82
81With the assumption that accessing the labels $(u, w)$ takes $\mathcal{O}(1)$ time this algorithm has the same running time as BFS; $\mathcal{O}(m+n)$. 83With the assumption that accessing the labels $(u, w)$ takes $\mathcal{O}(1)$ time this algorithm has the same running time as BFS; $\mathcal{O}(m+n)$.
82 84
83
84\section{Reachability}% 85\section{Reachability}%
85\label{sec:reachability} 86\label{sec:reachability}
86 87
88First, compute all strongly connected components (SCCs) of $G$ by using~\parencite{tarjanDepthFirst1972} per \emph{page 72} of the \nth{3} lecture notes in $\mathcal{O}(E+V)$ time. Instead of labelling the SCCs with the root node, we will initially label all nodes of the SCC $F'$ with the $min(u)$ of the connected component.
89
90Then, by ignoring the tree edges, shrink the graph $G$ such that $E' = {(v, w)~|~v \in F', w \in F''}$, leaving only cross links behind. This step takes another $\mathcal{O}(E+V)$ time.
91
92Now run the topological sort algorithm presented in \emph{page 84} of the \nth{3} lecture notes this operation is yet again $\mathcal{O}(E+V)$.
93
94Finally, reverse the direction of the edges on the graph that have been output by the topological sort and starting from the new root node, traverse the graph downwards and update the $min(u)$ of every SCC as follows;
95
96{\centering
97 \begin{minipage}{.7\linewidth}
98 \begin{algorithm}[H]
99 \DontPrintSemicolon{}
100 \SetAlgoLongEnd{}
101 \KwData{$G'$ = topological sorted G with reversed edges}
102 \KwResult{$\min(u)$ for all vertices $u \in V$}
103 $\text{mostmin} \longleftarrow \min(\text{root})$\;
104 \While{traversing $G'$ downwards with current node $v$}{
105 \uIf{$\min(v) < mostmin$}{
106 $\text{mostmin} \longleftarrow \min(v)$\;
107 }
108 \Else{
109 label $v$ as $mostmin$
110 }
111 }
112 \caption{Updating $\min(u)$ of the SCCs}%
113 \label{alg:question_2}
114 \end{algorithm}
115 \end{minipage}
116 \par
117}
118
119\printbibliography
120
87\end{document} 121\end{document}
diff --git a/structure.tex b/structure.tex
index 5f53a93..c504c76 100644
--- a/structure.tex
+++ b/structure.tex
@@ -35,6 +35,9 @@
35\usepackage[super]{nth} 35\usepackage[super]{nth}
36\usepackage{caption} 36\usepackage{caption}
37\usepackage{tikz} 37\usepackage{tikz}
38\usepackage[style=authoryear]{biblatex}
39
40
38 41
39\lstset{ 42\lstset{
40 basicstyle=\ttfamily, % Typeset listings in monospace font 43 basicstyle=\ttfamily, % Typeset listings in monospace font