summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYigit Sever2020-12-02 00:29:04 +0300
committerYigit Sever2020-12-02 00:29:04 +0300
commit18539f03d200fb94d59f102207213c3c80cdc5d7 (patch)
treebbba81b4f4fb1bb747833ee6b913c64c28065e6d
parenta10bc230a9644e0a951b62c1450f25aec698a063 (diff)
downloadhw3-main.tar.gz
hw3-main.tar.bz2
hw3-main.zip
Include the answer to third questionHEADmain
both a and b
-rw-r--r--answer_sheet/main.pdfbin169720 -> 194172 bytes
-rw-r--r--answer_sheet/main.tex32
-rw-r--r--answer_sheet/quiver.sty36
-rw-r--r--answer_sheet/structure.tex1
4 files changed, 69 insertions, 0 deletions
diff --git a/answer_sheet/main.pdf b/answer_sheet/main.pdf
index 7e9b4c4..5d1a4d4 100644
--- a/answer_sheet/main.pdf
+++ b/answer_sheet/main.pdf
Binary files differ
diff --git a/answer_sheet/main.tex b/answer_sheet/main.tex
index 002a755..67e2b09 100644
--- a/answer_sheet/main.tex
+++ b/answer_sheet/main.tex
@@ -98,5 +98,37 @@ Our algorithm is then as follows;
98 98
99The cycle checking step, step 2 in the algorithm above uses the Union Find. Since we did not go into the detail of Union Find in the lectures we will use the naive approach which uses $\mathcal{O}(n^{2})$ operations. On top of that, we have to run Kruskal's algorithm twice for $T_{r}$ and $T_{w}$ which runs in order $\mathcal{O}(k\log(n))$ ($k$ can be substituted with the number of white edges, if higher). Overall, the runtime of the algorithm is $\mathcal{O}(n^{2} k\log(n))$. 99The cycle checking step, step 2 in the algorithm above uses the Union Find. Since we did not go into the detail of Union Find in the lectures we will use the naive approach which uses $\mathcal{O}(n^{2})$ operations. On top of that, we have to run Kruskal's algorithm twice for $T_{r}$ and $T_{w}$ which runs in order $\mathcal{O}(k\log(n))$ ($k$ can be substituted with the number of white edges, if higher). Overall, the runtime of the algorithm is $\mathcal{O}(n^{2} k\log(n))$.
100 100
101\section{Shortest-paths and min spanning trees}%
102\label{sec:shortest_paths_and_min_spanning_trees}
103
104\subsection{a}%
105\label{sub:a}
106
107We will assume the tree of shortest paths is a spanning tree (otherwise node $s$ on its own is a tree and the answer is trivial).
108
109For a graph $G = (V, E)$, we can have $T = (V, E')$ which is a tree of shortest paths and a minimum spanning tree $T' = (V, E'')$. Take any edge incident to $s$ and call it $k$. $k = (s, x)$ is the minimum weighted edge from $s$ to $x$ per definition of the tree of shortest paths. Suppose that the MST $T'$ does not include $k$. This implies that there exists a path in $T'$ $s \leadsto x$ that does not include $k$. Adding $k$ to the MST will introduce a cycle but we can break this cycle by using the Cycle property given in the Greedy Algorithms II lecture notes. Since $k = (s, x)$ is the minimum weighted edge, it will not get deleted which means MST should have included $k$ to begin with.
110
111So it is not possible for a tree of shortest paths and a MST to not share any edges.
112
113\[\begin{tikzcd}
114 {x} \\
115 {s} \\
116 & {S}
117 \arrow[from=2-1, to=3-2, dashed, no head]
118 \arrow[from=3-2, to=1-1, curve={height=24pt}, no head]
119 \arrow["{k}"', from=1-1, to=2-1, no head]
120\end{tikzcd}\]
121
122
123\subsection{b}%
124\label{sub:b}
125
126Given the acyclic digraph $G = (V, E)$ and an arborescence $A \subset E$ with the given conditions in the question text, $A$ itself is then a minimum cost arborescence in $G$. Take any $e = (v, t) \in A$. If $e$ is part of some minimum cost arborescence in $G$ then it is the cheapest incoming edge for $t$ per the lecture notes. $A$ is built up from such $e$ and the algorithm for building an arborescence in $G$ per the lecture notes is picking the cheapest incoming edge for every node and the graph $G$ is acyclic meaning that we cannot form accidental cycles by including every $e \in E$, $A$ is a minimum-cost arborescence in $G$.
127
128
129
130
131
132
101 133
102\end{document} 134\end{document}
diff --git a/answer_sheet/quiver.sty b/answer_sheet/quiver.sty
new file mode 100644
index 0000000..57d154b
--- /dev/null
+++ b/answer_sheet/quiver.sty
@@ -0,0 +1,36 @@
1% *** quiver ***
2% A package for drawing commutative diagrams exported from https://q.uiver.app.
3%
4% This package is currently a wrapper around the `tikz-cd` package, importing necessary TikZ
5% libraries, and defining a new TikZ style for curves of a fixed height.
6%
7% Version: 1.0.1
8% Authors:
9% - varkor (https://github.com/varkor)
10% - AndréC (https://tex.stackexchange.com/users/138900/andr%C3%A9c)
11
12\NeedsTeXFormat{LaTeX2e}
13\ProvidesPackage{quiver}[2020/11/27 quiver]
14
15% `tikz-cd` is necessary to draw commutative diagrams.
16\RequirePackage{tikz-cd}
17% `calc` is necessary to draw curved arrows.
18\usetikzlibrary{calc}
19% `pathmorphing` is necessary to draw squiggly arrows.
20\usetikzlibrary{decorations.pathmorphing}
21
22% A TikZ style for curved arrows of a fixed height, due to AndréC.
23\tikzset{curve/.style={settings={#1},to path={(\tikztostart)
24 .. controls ($(\tikztostart)!\pv{pos}!(\tikztotarget)!\pv{height}!270:(\tikztotarget)$)
25 and ($(\tikztostart)!1-\pv{pos}!(\tikztotarget)!\pv{height}!270:(\tikztotarget)$)
26 .. (\tikztotarget)\tikztonodes}},
27 settings/.code={\tikzset{quiver/.cd,#1}
28 \def\pv##1{\pgfkeysvalueof{/tikz/quiver/##1}}},
29 quiver/.cd,pos/.initial=0.35,height/.initial=0}
30
31% TikZ arrowhead/tail styles.
32\tikzset{tail reversed/.code={\pgfsetarrowsstart{tikzcd to}}}
33\tikzset{2tail/.code={\pgfsetarrowsstart{Implies[reversed]}}}
34\tikzset{2tail reversed/.code={\pgfsetarrowsstart{Implies}}}
35
36\endinput
diff --git a/answer_sheet/structure.tex b/answer_sheet/structure.tex
index 77d3e4c..5a9fcbe 100644
--- a/answer_sheet/structure.tex
+++ b/answer_sheet/structure.tex
@@ -34,6 +34,7 @@
34\usepackage{caption} 34\usepackage{caption}
35\usepackage{tikz} 35\usepackage{tikz}
36\usepackage{subcaption} 36\usepackage{subcaption}
37\usepackage{quiver}
37\usetikzlibrary{arrows,fit,positioning} 38\usetikzlibrary{arrows,fit,positioning}
38\usepackage[style=authoryear]{biblatex} 39\usepackage[style=authoryear]{biblatex}
39 40