\documentclass{article}
\usepackage{fourier}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{extramarks}
\usepackage[usenames,dvipsnames]{color}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{courier}
\usepackage[english]{babel}
\usepackage{amsmath,amsfonts,amsthm}
\usepackage{pdfpages}
\usepackage{color}
\usepackage{float}
\usepackage{tabularx}
\PassOptionsToPackage{hyphens}{url}\usepackage{hyperref}
\usepackage{subfig}
\usepackage{scalefnt}
\restylefloat{table}
\topmargin=-0.45in
\evensidemargin=0in
\oddsidemargin=0in
\textwidth=6.5in
\textheight=9.0in
\headsep=0.25in
\linespread{1.1}
\pagestyle{fancy}
\lhead{\hmwkAuthorName}
\chead{\hmwkClass: \hmwkTitle}
\rhead{\firstxmark}
\lfoot{\lastxmark}
\cfoot{}
\rfoot{Page\ \thepage\ of\ \protect\pageref{LastPage}}
\renewcommand\headrulewidth{0.4pt}
\renewcommand\footrulewidth{0.4pt}
\setlength\parindent{0pt}
\definecolor{MyDarkGreen}{rgb}{0.0,0.4,0.0}
\lstloadlanguages{Perl}
\lstset{language=Python,
frame=single,
basicstyle=\small\ttfamily,
keywordstyle=[1]\color{Blue}\bf,
keywordstyle=[2]\color{Purple},
keywordstyle=[3]\color{Blue}\underbar,
identifierstyle=,
commentstyle=\usefont{T1}{pcr}{m}{sl}\color{MyDarkGreen}\small,
stringstyle=\color{Purple},
showstringspaces=false,
tabsize=5,
morekeywords={rand},
morekeywords=[2]{on, off, interp},
morekeywords=[3]{test},
morecomment=[l][\color{Blue}]{...},
numbers=left,
firstnumber=1,
numberstyle=\tiny\color{Blue},
stepnumber=5
}
\newcommand{\pythonscript}[2]{
\begin{itemize}
\item[]\lstinputlisting[caption=#2,label=#1]{#1.py}
\end{itemize}
}
\newcommand{\enterProblemHeader}[1]{
\nobreak\extramarks{#1}{#1 continued on next page\ldots}\nobreak
\nobreak\extramarks{#1 (continued)}{#1 continued on next page\ldots}\nobreak
}
\newcommand{\exitProblemHeader}[1]{
\nobreak\extramarks{#1 (continued)}{#1 continued on next page\ldots}\nobreak
\nobreak\extramarks{#1}{}\nobreak
}
\setcounter{secnumdepth}{0}
\newcounter{homeworkProblemCounter}
\newcommand{\homeworkProblemName}{}
\newenvironment{homeworkProblem}[1][Problem \arabic{homeworkProblemCounter}]{
\stepcounter{homeworkProblemCounter}
\renewcommand{\homeworkProblemName}{#1}
\section{\homeworkProblemName}
\enterProblemHeader{\homeworkProblemName}
}{
\exitProblemHeader{\homeworkProblemName}
}
\newcommand{\problemAnswer}[1]{
\noindent\framebox[\columnwidth][c]{\begin{minipage}{0.98\columnwidth}#1\end{minipage}}
}
\newcommand{\homeworkSectionName}{}
\newenvironment{homeworkSection}[1]{
\renewcommand{\homeworkSectionName}{#1}
\subsection{\homeworkSectionName}
\enterProblemHeader{\homeworkProblemName\ [\homeworkSectionName]}
}{
\enterProblemHeader{\homeworkProblemName}
}
\newcommand{\hmwkTitle}{Homework\ 8}
\newcommand{\hmwkDueDate}{Thursday,\ October 30,\ 2014}
\newcommand{\hmwkClass}{Advanced Algorithmics}
\newcommand{\hmwkClassTime}{}
\newcommand{\hmwkClassInstructor}{}
\newcommand{\hmwkAuthorName}{Martin Valgur}
\title{
\vspace{2in}
\textmd{\textbf{\hmwkClass:\ \hmwkTitle}}\\
\normalsize\vspace{0.1in}\small{Due\ on\ \hmwkDueDate}\\
\vspace{0.1in}\large{\textit{\hmwkClassInstructor\ \hmwkClassTime}}
\vspace{3in}
}
\author{\textbf{\hmwkAuthorName}}
\date{\today}
\begin{document}
\newpage
\begin{homeworkProblem}
\textit{Use the same graph as from last week. Make the SCC component graph, and provide it's topological sort order.}\\
Sage worksheet with the source code of this solution: \url{https://cloud.sagemath.com/projects/b60781fb-41d7-40bf-97f4-94455eaaf2d4/files/HW8/Task\%201.sagews}.
\begin{figure}[H]
\label{fig:scc}
\centering
\includegraphics[width=1\textwidth]{T1_SCCs.pdf}
\caption{The graph with its vertices colored by the SCC they belong to.}
\end{figure}
\begin{figure}[H]
\label{fig:scc_topo}
\centering
\includegraphics[width=0.6\textwidth]{T1_toposort.pdf}
\caption{Topological ordering of the SCCs.}
\end{figure}
\end{homeworkProblem}
\clearpage
\begin{homeworkProblem}
\textit{Take the same graph as from task 1 (last week). Represent it in Adjacency Matrix presentation. Calculate the versions with exactly 2 hops and 3 hops. $G*G$ and $G*G*G$ respectively. Draw the "3-hop graph". Calculate the transitive closure by 1) $G*G*G*\cdots*G$ ; 2) Power steps: $G_2=G*G$ ; $G_4=G_2*G_2$ ; $G_8=G_4*G_4$ ; $G_{16}=G_8*G_8$, and 3) Warshall algorithm.}\\
Sage worksheet containing the source code of this solution: \url{https://cloud.sagemath.com/projects/b60781fb-41d7-40bf-97f4-94455eaaf2d4/files/HW8/Task\%202.sagews}.
\begin{figure}[H]
\hfill
\vcenter{\subfloat{
$\input{T2_G.tex}$
}}
\hspace*{-3in}
\vcenter{\subfloat{\includegraphics[width=0.4\textwidth]{T2_G.pdf} }}
\hfill
\caption{Adjacency matrix $G$.}
\end{figure}
\begin{figure}[H]
\hfill
\vcenter{\subfloat{
$\input{T2_G2.tex}$
}}
\hspace*{-3in}
\vcenter{\subfloat{\includegraphics[width=0.4\textwidth]{T2_G2.pdf} }}
\hfill
\caption{Adjacency matrix $G*G$.}
\end{figure}
\begin{figure}[H]
\hfill
\vcenter{\subfloat{
$\input{T2_G3.tex}$
}}
\hspace*{-3in}
\vcenter{\subfloat{\includegraphics[width=0.4\textwidth]{T2_G3.pdf} }}
\hfill
\caption{Adjacency matrix $G*G*G$.}
\end{figure}
\begin{figure}[H]
\hfill
\vcenter{\subfloat{
$\input{T2_tc.tex}$
}}
\hspace*{-3in}
\vcenter{\subfloat{\includegraphics[width=0.4\textwidth]{T2_tc.pdf} }}
\hfill
\caption{Transitive closure (calculated with either $((G+I)^N-I)$ or the Warshall algorithm).}
\end{figure}
\end{homeworkProblem}
\begin{homeworkProblem}
\textit{Take the same graph and run the simple random walk procedure along the graph. Treat all outbound links with equal probability. Report the proportion of time spent in each node. Add some edges to get rid of dead ends (to node C, for example K-C, I-C, G-C). And some edges to get into nodes that had no incoming links (D-J, D-L). Interpret the effect of those added links.}\\
See the Sage worksheet for this task: \url{https://cloud.sagemath.com/projects/b60781fb-41d7-40bf-97f4-94455eaaf2d4/files/HW8/Task\%203.sagews}.\\
The addition of edges to dead-end nodes got rid of all absorbing states. As a result the random walk can continue indefinitely and the probability of finishing the walk on a specific node does not depend on the starting node anymore.
\end{homeworkProblem}
\begin{homeworkProblem}
\textit{Explore the real graphs from here: \url{https://courses.cs.ut.ee/2013/algorithmics/spring/Main/HW8}. Select two graphs by your own choice. Describe the graphs - what they are about? Analyse the degree distribution; find how many components.}\\
See the Sage worksheet for this task: \url{https://cloud.sagemath.com/projects/b60781fb-41d7-40bf-97f4-94455eaaf2d4/files/HW8/Task\%204.sagews}.\\
\begin{itemize}
\item Enron -- directed graph of emails sent from person to person in the Enron company.
\item Students -- undirected graph of collaboration between students during a course, edges have different types to mark different types of collaboration.
\item US airlines -- directed graph of the number of flights between US airports. Surprisingly has many SCCs. The degree distribution obeys inverse power law.
\item Karate -- a small undirected graph of relationships between people who belong to either or both of two clubs.
\end{itemize}
\end{homeworkProblem}
\begin{homeworkProblem}
\textit{What is the diameter of your graphs (components) from 2? (you can estimate it also by running shortest distance not from all nodes, if computationally too slow. How slow?).}\\
See the Sage worksheet for this task (same as in task 4): \url{https://cloud.sagemath.com/projects/b60781fb-41d7-40bf-97f4-94455eaaf2d4/files/HW8/Task\%204.sagews}.\\
\end{homeworkProblem}
\begin{homeworkProblem}
\textit{Continue task nr 3. Represent it as a adjacency matrix with real-valued probabilities. Compare whether the matrix multiplication yields similar stationary distributions. Both on original and modified graph (with no dead ends or unreachable nodes). }\\
See the Sage worksheet for task 3: \url{https://cloud.sagemath.com/projects/b60781fb-41d7-40bf-97f4-94455eaaf2d4/files/HW8/Task\%203.sagews}.\\
\end{homeworkProblem}
\end{document}