diff options
author | Yigit Sever | 2020-11-15 03:43:42 +0300 |
---|---|---|
committer | Yigit Sever | 2020-11-15 03:43:42 +0300 |
commit | 4e978accd53ca8e368bf6adf6200a73d7ac5e4e1 (patch) | |
tree | 780b783a4d52f73a6a1f4993484d09062e063eb0 /main.tex | |
parent | e307e8a490d7e28cb7397f7cda3043bf728eca7e (diff) | |
download | hw2-4e978accd53ca8e368bf6adf6200a73d7ac5e4e1.tar.gz hw2-4e978accd53ca8e368bf6adf6200a73d7ac5e4e1.tar.bz2 hw2-4e978accd53ca8e368bf6adf6200a73d7ac5e4e1.zip |
Type the first draft of answer to question 1
Diffstat (limited to 'main.tex')
-rw-r--r-- | main.tex | 49 |
1 files changed, 49 insertions, 0 deletions
@@ -31,6 +31,55 @@ | |||
31 | \section{Checking Consistency of Judgements}% | 31 | \section{Checking Consistency of Judgements}% |
32 | \label{sec:checking_consistency_of_judgements} | 32 | \label{sec:checking_consistency_of_judgements} |
33 | 33 | ||
34 | Given the collection of $n$ butterflies and a potential judgement between every pair (or not if the judgement is ambiguous), we have a graph $G = (V, E)$ with $n = |V|$ vertices and $|E| = m \le \frac{n(n-1)}{2}$ edges, with every edge $(i, j) \in E$ labelled either \enquote{same} or \enquote{different}. At the end of our algorithm, the vertices should be \emph{consistently} labelled as either \texttt{A} and \texttt{B} or our algorithm should be able to prove that $G$ cannot be labelled as so. | ||
35 | |||
36 | A modified graph traversal using either BFS or DFS (since a node can be discovered multiple times in both of them) will work. Here we will modify the graph traversal given on \emph{page 42} on our \nth{3} lecture slides that uses BFS. The input of the algorithm is a node $s \in E$. If, due to ambiguous (i.e.\ missing) nodes, the graph is not connected, the algorithm should be run until every connected component is discovered. | ||
37 | % TODO: run until every cc is discovered is handwavey <15-11-20, yigit> % | ||
38 | |||
39 | {\centering | ||
40 | \begin{minipage}{.7\linewidth} | ||
41 | \begin{algorithm}[H] | ||
42 | \SetKwProg{Fn}{function}{}{end} | ||
43 | \DontPrintSemicolon{} | ||
44 | \SetAlgoLongEnd{} | ||
45 | \Fn{consistency\_check(s: node)}{ | ||
46 | \KwData{$K$ = data structure of discovered nodes} | ||
47 | \KwResult{boolean = whether $G$ is consistent or not} | ||
48 | \textbf{label} $s$ as \texttt{A} \tcc*[r]{the opposite label is B} | ||
49 | put $s$ in $K$\; | ||
50 | \While{$K$ is not empty}{ | ||
51 | take a node $v$ from $K$\; | ||
52 | \If{$v$ is not marked \enquote{explored}}{ | ||
53 | mark $v$ \enquote{explored}\; | ||
54 | \For{each edge $(v, w)$ incident to $v$}{ | ||
55 | \uIf{$w$ is labelled}{ | ||
56 | \If{the label of $w$ is not consistent with the label of $v$ with respect to the judgement $(v,w$)}{ | ||
57 | terminate the algorithm; $G$ is \textbf{inconsistent}\; | ||
58 | } | ||
59 | } | ||
60 | \Else{ | ||
61 | \uIf{$(v,w)$ is labelled \enquote{same}}{ | ||
62 | \textbf{label} $w$ with the label of $v$\; | ||
63 | } | ||
64 | \Else(\tcc*[f]{$(v,w)$ is labelled \enquote{different}}){ | ||
65 | \textbf{label} $w$ with the opposite label of $v$\; | ||
66 | } | ||
67 | } | ||
68 | put $w$ in $K$\; | ||
69 | } | ||
70 | } | ||
71 | } | ||
72 | the spanned connected component is \textbf{consistent} | ||
73 | } | ||
74 | \caption{Modified graph traversal algorithm so solve judgement consistency checking problem}% | ||
75 | \label{alg:question_1} | ||
76 | \end{algorithm} | ||
77 | \end{minipage} | ||
78 | \par | ||
79 | } | ||
80 | |||
81 | With 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 | |||
34 | 83 | ||
35 | \section{Reachability}% | 84 | \section{Reachability}% |
36 | \label{sec:reachability} | 85 | \label{sec:reachability} |