Latex is a very useful tool for the researchers in making research publications. In this post we will see writing algorithms/pseudocodes in Latex, through an example.
\documentclass{article} \usepackage[utf8]{inputenc} \title{Sample} \author{Pradeeban Kathiravelu} \date{December 2015} \usepackage{algpseudocode} \usepackage{algorithm} \usepackage{xcolor} \begin{document} \maketitle \section{Introduction} \begin{algorithm}[ht] \fontsize{9}{9}\selectfont \caption{\textit{$\partial$u$\partial$u} Initialization} \label{alg:init} \begin{algorithmic}[1] \Procedure{\textit{$initialize$}}{$nodes$, $policy$} \State \colorbox{blue!10}{$blockingKeySet$ $\gets$ $policy.getBlockingKeySet()$} \ForAll { \colorbox{red!10}{($node$ \textbf{in} $nodes$)}} \par \Comment {Let all the nodes join the coordinator cluster.} \State \colorbox{green!10}{$joinCluster(node,coordinator)$} \EndFor \State \colorbox{green!10}{$adaptiveScale(blockingKeySet, policy)$} \par \Comment {Monitors the health and scale the clusters accordingly.} \ForAll { \colorbox{red!10}{($blockingKey$ \textbf{in} $blockingKeySet$})} \State \colorbox{blue!10}{$index$ $\gets$ $generateIndex(nodes.count())$} \par \Comment {At least one node joins a cluster.} \State \colorbox{green!10}{$joinCluster(nodes.get(index),blockingKey)$} \EndFor \State \colorbox{green!10}{$initDataSourcesIntegrator()$} \State \colorbox{green!10}{$initDataWarehouseIntegrator()$} \EndProcedure \end{algorithmic} \end{algorithm} \end{document}
The outcome will look as below:
Green background denotes executions. Blue background denotes data and data structure initializations. Red indicates a condition. The above code segment also includes the line numbers and comments.
The above Latex code segment and the respective algorithm are borrowed from the publication:
"Kathiravelu,
Pradeeban; Galhardas, Helena; Veiga, Luís; ",∂u∂u Multi-Tenanted
Framework: Distributed Near Duplicate Detection for Big Data,On the Move
to Meaningful Internet Systems: OTM 2015
Conferences,,,237-256,2015,Springer International Publishing. link.springer.com/chapter/10.1007/978-3-319-26148-5_14
No comments:
Post a Comment
You are welcome to provide your opinions in the comments. Spam comments and comments with random links will be deleted.