Tuesday, December 22, 2015

Pretty Printing Algorithms and Pseudocodes in Latex

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.


\author{Pradeeban Kathiravelu}
\date{December 2015}





 \caption{\textit{$\partial$u$\partial$u} Initialization}
\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)$}
\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)$} 
\State  \colorbox{green!10}{$initDataSourcesIntegrator()$}   
\State  \colorbox{green!10}{$initDataWarehouseIntegrator()$}   

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.