<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8083898279613891327</id><updated>2025-07-19T22:25:05.413+05:30</updated><category term="Algorithms"/><category term="Java"/><category term="PHP"/><category term="Learn-Fast"/><category term="Go (Golang)"/><category term="Infrastructure Setup"/><title type='text'>Codispatch</title><subtitle type='html'>Tutorials and inspirational resources for software engineers to bring light for their creativity and work</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://codispatch.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://codispatch.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Codispatch</name><uri>http://www.blogger.com/profile/10792272971034892579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>11</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8083898279613891327.post-6487404071051918643</id><published>2022-06-20T03:03:00.008+05:30</published><updated>2024-06-22T13:05:23.812+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Infrastructure Setup"/><category scheme="http://www.blogger.com/atom/ns#" term="Learn-Fast"/><title type='text'>Install Harvester on Bare Metal Cloud using ISO Image</title><content type='html'>&lt;!--adsense--&gt;

Rancher Harvester is an open-source hyper-converged infrastructure platform designed to run modern cloud-native workloads on bare metal servers and it is completely open-source and free to use. Traditional Type 1 Hypervisors are complicated to set up on bare-metal hardware and it usually involves many storages, network, and other peripheral device configurations. We will cover on deploying rancher harvester on bare metal cloud instance and setting up your first virtual machine in rancher harvester. I am going to use vultr as a bare-metal cloud provider (&lt;a href=&quot;https://www.vultr.com/?ref=9162771-8H&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Get $100 free vultr credit to setup your harvester cluster&lt;/a&gt;), you can use any cloud provider or you can even use your HomeLab/Self Hosted environments.&lt;div&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEia2PUjUo4Ot-YLrMfvdf6UfIRJrh-H_OiQF8I6szu_2CNeAuXbdNk7-jyfeb0OIimx3Fwnhqe7eOpGQj10wTLHlnpyvyJWqTuv3I_Bk0T40M3cxNdSmLgJ2wl_5fhyUQaaShA5CGVnR4BNQT995mKuoVH5P5L1VTYk2tQeNpxcmAWQN3hES7CAdeg/s1600/harvester.png&quot; style=&quot;display: block; padding: 1em 0px; text-align: center;&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; data-original-height=&quot;422&quot; data-original-width=&quot;811&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEia2PUjUo4Ot-YLrMfvdf6UfIRJrh-H_OiQF8I6szu_2CNeAuXbdNk7-jyfeb0OIimx3Fwnhqe7eOpGQj10wTLHlnpyvyJWqTuv3I_Bk0T40M3cxNdSmLgJ2wl_5fhyUQaaShA5CGVnR4BNQT995mKuoVH5P5L1VTYk2tQeNpxcmAWQN3hES7CAdeg/s1600/harvester.png&quot; /&gt;&lt;/a&gt;&lt;div&gt;&lt;a href=&quot;https://harvesterhci.io/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Rancher Harvester&lt;/a&gt; is built on top of Kubernetes using&lt;br /&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://longhorn.io/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Longhorn&lt;/a&gt; - lightweight, reliable, and easy-to-use distributed block storage system for Kubernetes.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://github.com/rancher-sandbox/cOS-toolkit&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Elemental for openSUSE Leap 15.3&lt;/a&gt; - Linux distribution designed to remove as much OS maintenance as possible in a Kubernetes cluster.&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://kubevirt.io/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;KubeVirt&lt;/a&gt; - virtual machine management add-on for Kubernetes which leverages KVM and libvirt to allow running virtual machines inside of Kubernetes cluster.&lt;/li&gt;&lt;/ul&gt;


&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;b&gt;Installation&lt;/b&gt;&lt;/h3&gt;&lt;div&gt;Login to your&amp;nbsp;&lt;a href=&quot;https://my.vultr.com/deploy/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;vultr management console&lt;/a&gt; and click on deploy a new server.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuXyzP1LGB7g8I3vhPjr2ZFu8Ya-zUNlzF5ij7l5QWDqcmYZw6-djjh4-WHQlMDc2RCBc5c3bDliRWxo3okQEsM2IUzjk0U1QSFpPdNhPlR919Ao-5WD4rCyLyPJh_kZkmgHSt4c_6_yoF0ikMERE4MqEIMKoIRjHMV4QbGihVFm-TYqoP3tBeaxE/s1361/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Vultr Management Console&quot; border=&quot;0&quot; data-original-height=&quot;727&quot; data-original-width=&quot;1361&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuXyzP1LGB7g8I3vhPjr2ZFu8Ya-zUNlzF5ij7l5QWDqcmYZw6-djjh4-WHQlMDc2RCBc5c3bDliRWxo3okQEsM2IUzjk0U1QSFpPdNhPlR919Ao-5WD4rCyLyPJh_kZkmgHSt4c_6_yoF0ikMERE4MqEIMKoIRjHMV4QbGihVFm-TYqoP3tBeaxE/s16000/vultr.png&quot; title=&quot;Vultr Management Console&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Select bare metal cloud instance, select server location, select initial pre-installed OS, and select server size and disk configuration. You can enable IPv6&amp;nbsp;&amp;nbsp;(optional) and add an SSH key. Give hostname to your instance. Click on deploy.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeFPn5aC7MPUGsGOXVM-qAkDWVKwoT6SjonPW7nyyuxOKacj3QSVg0-ERfwlWoaaUMiSBn0PqQ9BhPuh_KJz6VRAAJaQ3UnP_BnPOgD0y9tqXOtCYErt6-AsT4EAaUc3OKEX4v0r_z3bnTdLOAZrToFgBZeOzAL9H2dgA5ztBG-zIaZjfwZlR8OH4/s3577/vultr%20deploy.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Vultr Bare Metal&quot; border=&quot;0&quot; data-original-height=&quot;3577&quot; data-original-width=&quot;1269&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgeFPn5aC7MPUGsGOXVM-qAkDWVKwoT6SjonPW7nyyuxOKacj3QSVg0-ERfwlWoaaUMiSBn0PqQ9BhPuh_KJz6VRAAJaQ3UnP_BnPOgD0y9tqXOtCYErt6-AsT4EAaUc3OKEX4v0r_z3bnTdLOAZrToFgBZeOzAL9H2dgA5ztBG-zIaZjfwZlR8OH4/s16000/vultr%20deploy.png&quot; title=&quot;Rancher Harvester Vultr Bare Metal&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;It will take a couple of minutes to provision and spin up your new server instance, So please be patient. I have selected a 2 * 240 GB SSD instance. So we will get two disk partitions /dev/sda and /dev/sdb. In /dev/sda (this has pre-installed Ubuntu 22.04 LTS OS running on it) and &lt;b&gt;/dev/sdb&lt;/b&gt; which is formatted empty drive.&amp;nbsp;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYzo6jZqYeIhnfa8VJpLhWenx3axPgLtchr-EjrUiVJe0f8SbI_H1TnT5OJYrVCObrSMXUQN7vpqq86yVJosVeWVw-alRUG6Y9Dib6ib0n2BGdfzIl7SXK7zoQ3UV70Ba_lGdrkRi3YjRaYl-2rrblFUfJu6MxD3smkBgp-NiwtSb_IiCM_z2spBA/s1386/vultr_instance_up.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Vultr Instance Up&quot; border=&quot;0&quot; data-original-height=&quot;730&quot; data-original-width=&quot;1386&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYzo6jZqYeIhnfa8VJpLhWenx3axPgLtchr-EjrUiVJe0f8SbI_H1TnT5OJYrVCObrSMXUQN7vpqq86yVJosVeWVw-alRUG6Y9Dib6ib0n2BGdfzIl7SXK7zoQ3UV70Ba_lGdrkRi3YjRaYl-2rrblFUfJu6MxD3smkBgp-NiwtSb_IiCM_z2spBA/s16000/vultr_instance_up.png&quot; title=&quot;Rancher Harvester Vultr Instance Up&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Click on the server instance, and you will find the server IP, username, and password. ssh into the server instance using the server username and server password which is given in the vultr server management console.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXdTzzAQ15hoxdfuZpVkrGgql4JE8m75719LD1xixYhSeU0JXpV39W0pKKFlpu_6oPyWDsPpFDYEzw_M6vT0za3l5OeQfZ3c93pmv3Sob8VBovoo7SnG0bOok7-1Wqwf0QflVzYVJ76aeU4UeERs1AfZk07iyyVYci3w9KdfyM2LWXvoyyeXDcHSQ/s1343/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Vultr ssh to console&quot; border=&quot;0&quot; data-original-height=&quot;654&quot; data-original-width=&quot;1343&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXdTzzAQ15hoxdfuZpVkrGgql4JE8m75719LD1xixYhSeU0JXpV39W0pKKFlpu_6oPyWDsPpFDYEzw_M6vT0za3l5OeQfZ3c93pmv3Sob8VBovoo7SnG0bOok7-1Wqwf0QflVzYVJ76aeU4UeERs1AfZk07iyyVYci3w9KdfyM2LWXvoyyeXDcHSQ/s16000/vultr.png&quot; title=&quot;Vultr ssh to console&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Run the below commands in your terminal. This will download the rancher harvester ISO image from Harvester &lt;a href=&quot;https://github.com/harvester/harvester/releases&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Github Release&lt;/a&gt;&amp;nbsp;and it will mount the ISO image as a harvester installer to our empty /dev/sdb drive and finally reboots the server. Your ssh terminal should get disconnected and you can close the terminal.&lt;/div&gt;

&lt;pre&gt;&lt;code class=&quot;go-html&quot;&gt;
sudo apt update
wget https://releases.rancher.com/harvester/v1.0.2/harvester-v1.0.2-amd64.iso
umount /dev/sdb1
dd bs=1M conv=fdatasync if=./harvester-v1.0.2-amd64.iso of=/dev/sdb
reboot
&lt;/code&gt;&lt;/pre&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;While the server boots up, click on View Console (right top monitor icon) in&amp;nbsp;&lt;a href=&quot;https://my.vultr.com&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;vultr management console&lt;/a&gt;. Next when seeing the below screen start hitting the &lt;b&gt;F11 key&lt;/b&gt; on your keyboard to take you to the boot menu screen.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgruBSDG0BE8BfmiQDR9w60dIEue40TaY5R1c6-PIl66C5jcR_zHvbMg16Jp7dvsQif9KHJfZi7FkXuoqVle-nlRol-Cd6jPYNEASVvnzBlefBrLJh16k64XoUEWQTLpCjN83-Nl0h6WMC051Sy6Fqekb9Y8j8LPuUuxAY90jjBSpiXuX_ZZ2j7BF4/s1347/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Vultr Boot Menu&quot; border=&quot;0&quot; data-original-height=&quot;657&quot; data-original-width=&quot;1347&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgruBSDG0BE8BfmiQDR9w60dIEue40TaY5R1c6-PIl66C5jcR_zHvbMg16Jp7dvsQif9KHJfZi7FkXuoqVle-nlRol-Cd6jPYNEASVvnzBlefBrLJh16k64XoUEWQTLpCjN83-Nl0h6WMC051Sy6Fqekb9Y8j8LPuUuxAY90jjBSpiXuX_ZZ2j7BF4/s16000/vultr.png&quot; title=&quot;Vultr Boot Menu&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;You should see boot menu screen like below. This is the place where you can enter boot setup and change the boot order.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqa9mdSTdWcGEyrYC6IqsoAyy5WW414ByNwYQhJI-ukchHq4g-MjsMj5DvBnmEaMpz9BntAfLIbtwXvnnkkIbOggUlPN09NFgZ2GwK9bz1Tyow0Pt18T4pZqZLTW9IYpBBlX-JvgJu8Q5ELbXI_6U2fIKwDHhVrSfYKC7cqQ2vi6P4G0il7KRTcCU/s1340/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Vultr Boot Menu Options&quot; border=&quot;0&quot; data-original-height=&quot;647&quot; data-original-width=&quot;1340&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqa9mdSTdWcGEyrYC6IqsoAyy5WW414ByNwYQhJI-ukchHq4g-MjsMj5DvBnmEaMpz9BntAfLIbtwXvnnkkIbOggUlPN09NFgZ2GwK9bz1Tyow0Pt18T4pZqZLTW9IYpBBlX-JvgJu8Q5ELbXI_6U2fIKwDHhVrSfYKC7cqQ2vi6P4G0il7KRTcCU/s16000/vultr.png&quot; title=&quot;Vultr Boot Menu Options&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Select UEFI OS ( P3: Intel SSDSC2BB240G7 ) and press enter. (Basically, it means you are selecting to boot from &lt;b&gt;/dev/sdb&lt;/b&gt; drive which has a harvester installer ISO image mounted on it)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRWwHgf0TKDn-0w3SMVrXeHsbNz4HD5ccJii7Bcbl1mQ5qtskKmf2Yp7zchoqA7bcgeO0xKL1KIzbb8qclrTshwoyMjYKDxFjVVLTB3rSoAv44CJPRTOpnWWDCeNM9LNaY7lP3cQb2Xqnc0gwh0YkmyxsNzkOE0vMLSz7Yr32ruO8uBApug00KVvk/s1348/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Installation&quot; border=&quot;0&quot; data-original-height=&quot;656&quot; data-original-width=&quot;1348&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRWwHgf0TKDn-0w3SMVrXeHsbNz4HD5ccJii7Bcbl1mQ5qtskKmf2Yp7zchoqA7bcgeO0xKL1KIzbb8qclrTshwoyMjYKDxFjVVLTB3rSoAv44CJPRTOpnWWDCeNM9LNaY7lP3cQb2Xqnc0gwh0YkmyxsNzkOE0vMLSz7Yr32ruO8uBApug00KVvk/s16000/vultr.png&quot; title=&quot;Rancher Harvester Installation&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Select Harvester Installer v1.0.2 and press enter. It will take a few minutes to boot the kernel and it should show you the below screen.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLvnXhzfq0GpcNCFcSpuKoKxLanl8n-MG_oJOXx3rw49CKTTPlx1gTBftosPhE8AstGD6w0x3We5gDBKqdEjOEkzxY0ppVPgAmV8gOVOw0F_LgpbLbBuS7rI3Szs0LO2pnZUSPcnO8b0umqz8VzNBc2D8WOp5OIBQSGETZdlCB-tp7oW7eX4zBbkM/s1350/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Installation New cluster&quot; border=&quot;0&quot; data-original-height=&quot;660&quot; data-original-width=&quot;1350&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLvnXhzfq0GpcNCFcSpuKoKxLanl8n-MG_oJOXx3rw49CKTTPlx1gTBftosPhE8AstGD6w0x3We5gDBKqdEjOEkzxY0ppVPgAmV8gOVOw0F_LgpbLbBuS7rI3Szs0LO2pnZUSPcnO8b0umqz8VzNBc2D8WOp5OIBQSGETZdlCB-tp7oW7eX4zBbkM/s16000/vultr.png&quot; title=&quot;Rancher Harvester Installation New Cluster&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Select Create new harvester cluster. You can select join the existing harvester cluster if you already have the harvester cluster up and running.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-EfLB-6vye8K9bNSyYpFDu0NeP-SdxbvUCU_vO8VIx2vHIMqwdWu_bWkXubBtKq643of_lqtq_9ABmn6n6Am9qYzRk40ixzVrkng6ciHO5Y1NJ0KpI4ua-JC0pDS5PJNBIBZeCk67us9e7M8XZojKH-KnrB9pOSAraLk_VRlTTUFbfVCmFP4cDV8/s1350/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Installation Partitions&quot; border=&quot;0&quot; data-original-height=&quot;659&quot; data-original-width=&quot;1350&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-EfLB-6vye8K9bNSyYpFDu0NeP-SdxbvUCU_vO8VIx2vHIMqwdWu_bWkXubBtKq643of_lqtq_9ABmn6n6Am9qYzRk40ixzVrkng6ciHO5Y1NJ0KpI4ua-JC0pDS5PJNBIBZeCk67us9e7M8XZojKH-KnrB9pOSAraLk_VRlTTUFbfVCmFP4cDV8/s16000/vultr.png&quot; title=&quot;Rancher Harvester Installation Partitions&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Next, you get the option to choose the drive to install Harvester. We select &lt;b&gt;sda 223.6G. &lt;/b&gt;Remember,&amp;nbsp;We have two disk partitions&lt;b&gt; /dev/sda&lt;/b&gt; and&lt;b&gt; /dev/sdb&lt;/b&gt;. In &lt;b&gt;/dev/sda&lt;/b&gt; (this has pre-installed Ubuntu 22.04 LTS OS running on it) and&amp;nbsp;&lt;b&gt;/dev/sdb &lt;/b&gt;we have a harvester installer (currently we booted from this). We are going to erase and remove Ubuntu OS from&amp;nbsp;&lt;b&gt;/dev/sda &lt;/b&gt;and install &lt;b&gt;Harvester v1.0.4 &lt;/b&gt;in&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;b&gt;/dev/sda.&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNpJ6n0oVL8OEF8Fk4WI68WDqKWg6pbCbfYUd5lB3cdNIRbUkC-htZPhI74gQH8Af3OE8QO9GUmHlFxJ2p3trFOlRvllhAA3nWlXD77s-n7H7hxMYsud3s0UnnW2gVdlMr2kTkT1UgCFiDXE_ANxMuHdux_R4XkorvU5NVvE1tDew5moTkoZw7oMY/s1344/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Installation Configuration&quot; border=&quot;0&quot; data-original-height=&quot;660&quot; data-original-width=&quot;1344&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNpJ6n0oVL8OEF8Fk4WI68WDqKWg6pbCbfYUd5lB3cdNIRbUkC-htZPhI74gQH8Af3OE8QO9GUmHlFxJ2p3trFOlRvllhAA3nWlXD77s-n7H7hxMYsud3s0UnnW2gVdlMr2kTkT1UgCFiDXE_ANxMuHdux_R4XkorvU5NVvE1tDew5moTkoZw7oMY/s16000/vultr.png&quot; title=&quot;Rancher Harvester Installation Configuration&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Enter the hostname and select Management NIC. You can also select Bond Mode and IPv4 method. I will leave it with default values. Press enter to continue. It will apply the network configurations.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsW66kxmrkI8JC-TOeTTKzuOYI1OKBE-AV86cIXFDLHught0Iw-vxrE6k7zZtDnHtzFiexnVoEEvWwApUV7Ox24Ex8KfPEIU4h0aAanbWTi_AERMUfOGZi1ChjgeywMrJm3PWSrFFFLq3jF9rNII0tgwZAt-BDmtgGe8ycvsO67vl3QjgLu9eZyxE/s1349/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Installation Configuration&quot; border=&quot;0&quot; data-original-height=&quot;656&quot; data-original-width=&quot;1349&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsW66kxmrkI8JC-TOeTTKzuOYI1OKBE-AV86cIXFDLHught0Iw-vxrE6k7zZtDnHtzFiexnVoEEvWwApUV7Ox24Ex8KfPEIU4h0aAanbWTi_AERMUfOGZi1ChjgeywMrJm3PWSrFFFLq3jF9rNII0tgwZAt-BDmtgGe8ycvsO67vl3QjgLu9eZyxE/s16000/vultr.png&quot; title=&quot;Rancher Harvester Installation Configuration&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;It will ask for configuring DNS servers. I will leave it empty and press enter. (Optional step)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIcwWpCN-Ugk7nh3l3x61U730Tj3yPdO1k1GNjJkXjsDKBD0XW-nAOJJtsncMH2GB_6oBKS9CMPPQ47HewYjxerc03AzYq_J4_Q3FliX3QhcH4I65RFlwNvLBrQC_JgHRSvmoR0J665jBtWn9bjl1UuHrZLvhcSHi7nBuQP9f3c247LDfimxuYh2w/s1346/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Installation Configuration&quot; border=&quot;0&quot; data-original-height=&quot;660&quot; data-original-width=&quot;1346&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIcwWpCN-Ugk7nh3l3x61U730Tj3yPdO1k1GNjJkXjsDKBD0XW-nAOJJtsncMH2GB_6oBKS9CMPPQ47HewYjxerc03AzYq_J4_Q3FliX3QhcH4I65RFlwNvLBrQC_JgHRSvmoR0J665jBtWn9bjl1UuHrZLvhcSHi7nBuQP9f3c247LDfimxuYh2w/s16000/vultr.png&quot; title=&quot;Rancher Harvester Installation Configuration&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Next, it will ask for configuring Virtual Private IP. I am giving it as a static method and &lt;b&gt;172.168.0.102&lt;/b&gt;. This is an important and mandatory step and make sure this is done right. The VIP IP address you can use anything that you want to use to expose your application.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNbr4QDH1sbEVQFNSV9XFurLIbEJR1rzytUGwaEDBluiyNvAgZNniO_Se6UrbFjF9gmHmevywUYa2f5fDibpwqYCsoLz5QIc-MPk9TF1XGqDaV1hLOFAqNZTSclfI1U2iH7Atg4r0O9ryKTW8uW5OzJ4pHhRn9WfAW0mTmG6j-BQHAXzIg4YtPuHk/s1348/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Installation Configuration&quot; border=&quot;0&quot; data-original-height=&quot;657&quot; data-original-width=&quot;1348&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNbr4QDH1sbEVQFNSV9XFurLIbEJR1rzytUGwaEDBluiyNvAgZNniO_Se6UrbFjF9gmHmevywUYa2f5fDibpwqYCsoLz5QIc-MPk9TF1XGqDaV1hLOFAqNZTSclfI1U2iH7Atg4r0O9ryKTW8uW5OzJ4pHhRn9WfAW0mTmG6j-BQHAXzIg4YtPuHk/s16000/vultr.png&quot; title=&quot;Rancher Harvester Installation Configuration&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Enter your cluster token, this will be used when you are joining the existing harvester cluster.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEib0DDg2dC5a0-KysotrGLeWKh3zJiflcVEgEWZk9RRIb3gK2ri2bu6_s-GFaYlz6C9W1mZFp270O2cckQY7UfGLslFAQmx95AmCFW3tqn9Bs-uKdaDNDzloxsfC5N-9qxNgoqPaObZiWW7evwA0XvumssDpP56B-6yT7wthVV6SC4Kcuz7tU3RWeQ/s1345/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Installation Configuration&quot; border=&quot;0&quot; data-original-height=&quot;657&quot; data-original-width=&quot;1345&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEib0DDg2dC5a0-KysotrGLeWKh3zJiflcVEgEWZk9RRIb3gK2ri2bu6_s-GFaYlz6C9W1mZFp270O2cckQY7UfGLslFAQmx95AmCFW3tqn9Bs-uKdaDNDzloxsfC5N-9qxNgoqPaObZiWW7evwA0XvumssDpP56B-6yT7wthVV6SC4Kcuz7tU3RWeQ/s16000/vultr.png&quot; title=&quot;Rancher Harvester Installation Configuration&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Enter the password and confirm the password. Press enter to continue.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpgXDCinHMvW2f1Wu7E8VGqcacfK3Z5Nf0ENEkY_UI8Fw0HhReMTOtHWQjk-w2PPJ7R3Jt3EoIBeuohePtUIKXDv5ca_GSYewwrEkPAbV-IzcPk5wmZ4XbiKc-ZyK9s5FtrQd4qbg7JdW8pb2pwpJ6IDA1ZCUIHJC0cCS2QjKgvO8vvnMTZRMFYpI/s1346/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Installation Configuration&quot; border=&quot;0&quot; data-original-height=&quot;658&quot; data-original-width=&quot;1346&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpgXDCinHMvW2f1Wu7E8VGqcacfK3Z5Nf0ENEkY_UI8Fw0HhReMTOtHWQjk-w2PPJ7R3Jt3EoIBeuohePtUIKXDv5ca_GSYewwrEkPAbV-IzcPk5wmZ4XbiKc-ZyK9s5FtrQd4qbg7JdW8pb2pwpJ6IDA1ZCUIHJC0cCS2QjKgvO8vvnMTZRMFYpI/s16000/vultr.png&quot; title=&quot;Rancher Harvester Installation Configuration&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Configuring NTP server. Use the default value and press enter.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHnqxhPFP2Zzh7ip52dIHCvSL1SalUDwQfSYR8UhCnFE1hOaTjpRpIk_uPe19hutSamusJfJ0fLmT6Ib2JNAKqo8HFFvlUN100hRWF4Y59-3dNYfZps3w3zb1AesgqBBl-kB45i-JC-KkFJZ0LRccwRpMxeSF367Ljm4QB9pUulM24Xmqo28xeMNE/s1347/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Installation Configuration&quot; border=&quot;0&quot; data-original-height=&quot;657&quot; data-original-width=&quot;1347&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHnqxhPFP2Zzh7ip52dIHCvSL1SalUDwQfSYR8UhCnFE1hOaTjpRpIk_uPe19hutSamusJfJ0fLmT6Ib2JNAKqo8HFFvlUN100hRWF4Y59-3dNYfZps3w3zb1AesgqBBl-kB45i-JC-KkFJZ0LRccwRpMxeSF367Ljm4QB9pUulM24Xmqo28xeMNE/s16000/vultr.png&quot; title=&quot;Rancher Harvester Installation Configuration&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Configuring Proxy. Leave it empty and press enter.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhewHslGpMPUJvJyp7S_kiK3mJZGs7La0DrQTj5wXRtGPpTSO9r3ZmFTBMe-LbNqkbPVsibbx51Pty1mFdokRkbg1XG0_bb0AbpMN1Dg3BBugvI6X0VWsZAisaIqmPHinZLu5knBOvq2RvAb4vwSId0IKIARjOmI3mpb06BT3AYG_7ZTR3tgHP_kNY/s1347/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Installation Configuration&quot; border=&quot;0&quot; data-original-height=&quot;654&quot; data-original-width=&quot;1347&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhewHslGpMPUJvJyp7S_kiK3mJZGs7La0DrQTj5wXRtGPpTSO9r3ZmFTBMe-LbNqkbPVsibbx51Pty1mFdokRkbg1XG0_bb0AbpMN1Dg3BBugvI6X0VWsZAisaIqmPHinZLu5knBOvq2RvAb4vwSId0IKIARjOmI3mpb06BT3AYG_7ZTR3tgHP_kNY/s16000/vultr.png&quot; title=&quot;Rancher Harvester Installation Configuration&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Configuring SSH/import SSH key. You can import it if you have one or leave it empty and press enter.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjX2YNvsWUBTVV-5NrjaEFCbKS3YQcdLSCkQNlvUPUqNJXK6jp2Wk8M3sIPy0-aO3loE7-gDZ4J5MaB_wTKIwYSu9PL_r78xxUWk7Pg38i22Y1Z_TG_4vNSYRQnYuU6qUuEKgL5v8AL1rWfHj_DaJSM7GgJJpWsoQIRxxocjL_PYJbyFQlsPCH92TI/s1346/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Installation Configuration&quot; border=&quot;0&quot; data-original-height=&quot;656&quot; data-original-width=&quot;1346&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjX2YNvsWUBTVV-5NrjaEFCbKS3YQcdLSCkQNlvUPUqNJXK6jp2Wk8M3sIPy0-aO3loE7-gDZ4J5MaB_wTKIwYSu9PL_r78xxUWk7Pg38i22Y1Z_TG_4vNSYRQnYuU6qUuEKgL5v8AL1rWfHj_DaJSM7GgJJpWsoQIRxxocjL_PYJbyFQlsPCH92TI/s16000/vultr.png&quot; title=&quot;Rancher Harvester Installation Configuration&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;Harvester remote configuration - You can add it if you have one or leave it empty and press enter.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVyEaP-ad40DCpiDgX8nQDQMZ6a2TZtSY3sJbfwpIMvJ7OcmtS-LqjDS7JA8MLgUYjOhwaeFuRmETCR12Irikn6DM6JYVelclDGGsmwm0v7_fqC4q8J09RPAUlzimJ6zmGv2a7o4wadcTj9vDs2dRK5qLgJqOWyDEznHw4tFV3YosG9hoMzzaxzvc/s1348/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Installation Summary&quot; border=&quot;0&quot; data-original-height=&quot;661&quot; data-original-width=&quot;1348&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVyEaP-ad40DCpiDgX8nQDQMZ6a2TZtSY3sJbfwpIMvJ7OcmtS-LqjDS7JA8MLgUYjOhwaeFuRmETCR12Irikn6DM6JYVelclDGGsmwm0v7_fqC4q8J09RPAUlzimJ6zmGv2a7o4wadcTj9vDs2dRK5qLgJqOWyDEznHw4tFV3YosG9hoMzzaxzvc/s16000/vultr.png&quot; title=&quot;Rancher Harvester Installation Summary&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Finally, it gives a summary and it will ask whether you want to erase and install the harvester. Select yes and press enter.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnUB4MgUCWpKCYrgnfEYg3AkCEDWKNofJCWPM85YCUar2aw8qU2YCCrofYWnxQ4WInrksJwYqI77QQTj35MQGxBSHboxg5o_HdnnT6Qkwk8ndnwjK1_qi0-L-VnL-SYd7ucZ-VI7fIG2MA2B2-1gopQBhCSXc-o7Ud1Yvps0SfEW5zPXcRGfeqCjc/s1348/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Installation&quot; border=&quot;0&quot; data-original-height=&quot;658&quot; data-original-width=&quot;1348&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnUB4MgUCWpKCYrgnfEYg3AkCEDWKNofJCWPM85YCUar2aw8qU2YCCrofYWnxQ4WInrksJwYqI77QQTj35MQGxBSHboxg5o_HdnnT6Qkwk8ndnwjK1_qi0-L-VnL-SYd7ucZ-VI7fIG2MA2B2-1gopQBhCSXc-o7Ud1Yvps0SfEW5zPXcRGfeqCjc/s16000/vultr.png&quot; title=&quot;Rancher Harvester Installation&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Installation should start. It will show you the installation progress. It will take a couple of minutes to complete the installation and finally, it automatically reboots the server.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqd0mu7jqSlCD0zHP3TBDuT2G-VhYhlsYdhJhLNAhYVVF1GqKxQt6KuSkGQjkKbtMNxFIaXN6nhh0aRtT4Y8PR-ILBprgIaSh7KfVZVS8jhMOC7mSQoyU_nrfhVe_aoIf_1VL89xJFfTBa0C8UUB-71mkRZzkK6Tm0txN_R9MZcYJJrD0U96QtnAA/s1350/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Vultr Boot Menu&quot; border=&quot;0&quot; data-original-height=&quot;657&quot; data-original-width=&quot;1350&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqd0mu7jqSlCD0zHP3TBDuT2G-VhYhlsYdhJhLNAhYVVF1GqKxQt6KuSkGQjkKbtMNxFIaXN6nhh0aRtT4Y8PR-ILBprgIaSh7KfVZVS8jhMOC7mSQoyU_nrfhVe_aoIf_1VL89xJFfTBa0C8UUB-71mkRZzkK6Tm0txN_R9MZcYJJrD0U96QtnAA/s16000/vultr.png&quot; title=&quot;Vultr Boot Menu&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;When the server boots up, press the&amp;nbsp;&lt;b&gt;F11 key&lt;/b&gt;&amp;nbsp;on your keyboard to take you to the boot menu screen and this time we are going to select UEFI OS ( P2: Intel SSDSC2BB240G7 ) and press enter. (Basically, it means you are selecting to boot from&amp;nbsp;&lt;b&gt;/dev/sda&lt;/b&gt;&amp;nbsp;drive which has a harvester installed)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNqXzejjTaGokQW98iOyKSCmx4GzWyxx_ie40cb-_Fv_2M8GmntmG3OXYaNbHzft65MW9H5nRPy794gZIE99mzqOcQBz_F3OHrmYi9O4jmmHja_VGcF3uwn-1iKa0uOROqYWUNA1WjPWZ3Yrb6NsETQHyLLBVtN51jUsXk7OH8ZumHDqi1yWrous8/s1345/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Boot&quot; border=&quot;0&quot; data-original-height=&quot;657&quot; data-original-width=&quot;1345&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhNqXzejjTaGokQW98iOyKSCmx4GzWyxx_ie40cb-_Fv_2M8GmntmG3OXYaNbHzft65MW9H5nRPy794gZIE99mzqOcQBz_F3OHrmYi9O4jmmHja_VGcF3uwn-1iKa0uOROqYWUNA1WjPWZ3Yrb6NsETQHyLLBVtN51jUsXk7OH8ZumHDqi1yWrous8/s16000/vultr.png&quot; title=&quot;Rancher Harvester Boot&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;Select Harvester v1.0.4 and press enter. You will be taken to the next screen which has the Rancher Harvester Management URL, IP address, and cluster state.&amp;nbsp; Please be patient, it will initially show cluster state as Unavailable, Not Ready, Setting Up, etc. After giving a couple of minutes it should show you the below screen.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhsTSLhIrL8pkTzdhV-HkiWaRYMh-ubjxNssmGoQIlUqOOB-CM8z6iN6KTuqu19EnnVXBMLvEML29pB4f3v9QDucb7slR7VXUAxc8IXULqzZxuDzVoIrKaz42xTE2V4qkG3dXo_Yl3HvhQgQk8qnGmmImwQlNlxKsM-03MApxXMq6_-f51DjbgpGM/s1349/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Management Console&quot; border=&quot;0&quot; data-original-height=&quot;657&quot; data-original-width=&quot;1349&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhsTSLhIrL8pkTzdhV-HkiWaRYMh-ubjxNssmGoQIlUqOOB-CM8z6iN6KTuqu19EnnVXBMLvEML29pB4f3v9QDucb7slR7VXUAxc8IXULqzZxuDzVoIrKaz42xTE2V4qkG3dXo_Yl3HvhQgQk8qnGmmImwQlNlxKsM-03MApxXMq6_-f51DjbgpGM/s16000/vultr.png&quot; title=&quot;Rancher Harvester Management Console&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;Congratulations, your Rancher Harvester cluster is Up. You can go to vultr public IP (&lt;a href=&quot;https://my.vultr.com&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;vultr management console&lt;/a&gt;) from the new browser tab and you should be able to setup rancher harvester UCM first-time login screen. Set your new password and click on continue.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWd2SwjhaCOYCj2yy1Rseyt5u5zfebB_BYx6tAoRttu3HS-PEITawayiCfpLqF9pykMstZn7_uv2XOUoiFRBTI2tYx2ukrPRj0x1d6_e6qAK2oK0eRIMgXlWM9_riD6D_R48ZRodWfFu1-c6IeH-JhOqZXKQb_JnM6aP6PEC8qcTdc42VxN6HTlco/s1366/vultr.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester Login Setup&quot; border=&quot;0&quot; data-original-height=&quot;728&quot; data-original-width=&quot;1366&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWd2SwjhaCOYCj2yy1Rseyt5u5zfebB_BYx6tAoRttu3HS-PEITawayiCfpLqF9pykMstZn7_uv2XOUoiFRBTI2tYx2ukrPRj0x1d6_e6qAK2oK0eRIMgXlWM9_riD6D_R48ZRodWfFu1-c6IeH-JhOqZXKQb_JnM6aP6PEC8qcTdc42VxN6HTlco/s16000/vultr.png&quot; title=&quot;Rancher Harvester Login Setup&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1OmRfkvmSFwK3uFL-fwKDLaWo3AYbuthVCgR0liauIEjyzoWs6hS0ciZo5GVK0QxdSvfixyolSR38v5GKz8jF7DHNmFhDrG8lRNPDMMG0IC9wTvZ--6U2aiAlDnKHfwDYvlUxQVFT-FdJ7-HIctzk2jzVb5DL-BrT27CS5pMcUal9hBfWqtL7AT4/s2015/Harveter.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Rancher Harvester UCM&quot; border=&quot;0&quot; data-original-height=&quot;2015&quot; data-original-width=&quot;1366&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1OmRfkvmSFwK3uFL-fwKDLaWo3AYbuthVCgR0liauIEjyzoWs6hS0ciZo5GVK0QxdSvfixyolSR38v5GKz8jF7DHNmFhDrG8lRNPDMMG0IC9wTvZ--6U2aiAlDnKHfwDYvlUxQVFT-FdJ7-HIctzk2jzVb5DL-BrT27CS5pMcUal9hBfWqtL7AT4/s16000/Harveter.png&quot; title=&quot;Rancher Harvester UCM&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;Wrapping Up&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;Thanks and congratulations on setting up your new harvester infrastructure. If you encountered any issues while setting up the cluster, please comment below. I have covered only the single node harvester setup process and will cover how to join existing harvester nodes to form a harvester cluster, Virtual Machine deployment, and Virtual Machine migration to a new harvester host/node in my upcoming posts. So stay tuned and happy developing infrastructure.&amp;nbsp;&amp;nbsp;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codispatch.blogspot.com/feeds/6487404071051918643/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codispatch.blogspot.com/2022/06/how-to-deploy-rancher-harvester-bare-metal-cloud.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/6487404071051918643'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/6487404071051918643'/><link rel='alternate' type='text/html' href='http://codispatch.blogspot.com/2022/06/how-to-deploy-rancher-harvester-bare-metal-cloud.html' title='Install Harvester on Bare Metal Cloud using ISO Image'/><author><name>Shravan C</name><uri>http://www.blogger.com/profile/07299338851374232212</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCkZjKG4qB0Hm70obtBjJFRtEdxW5Ui5iLXXHLbn9yi4TA14dHwN1KSlHF_GHXYtdiBCbFEOxWk4XGHqETjHVLLmQILELFkKXZPa18lkQzbrN3vvvqYL7HsgyJcSmb/s113/download.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEia2PUjUo4Ot-YLrMfvdf6UfIRJrh-H_OiQF8I6szu_2CNeAuXbdNk7-jyfeb0OIimx3Fwnhqe7eOpGQj10wTLHlnpyvyJWqTuv3I_Bk0T40M3cxNdSmLgJ2wl_5fhyUQaaShA5CGVnR4BNQT995mKuoVH5P5L1VTYk2tQeNpxcmAWQN3hES7CAdeg/s72-c/harvester.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8083898279613891327.post-7037544688526511096</id><published>2017-01-26T21:25:00.002+05:30</published><updated>2020-05-25T20:25:31.060+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Go (Golang)"/><title type='text'>Journey to Google&amp;#39;s Go (Golang) Programming Tutorial Series </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;!--adsense--&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Go or Golang is a general-purpose programming language and an open source programming language that makes it easy to build simple, reliable, and efficient software. It was created at Google by Robert Griesemer, Rob Pike, and Ken Thompson in 2007. In this post we&#39;ll be learning the Features of Go,What it is good for ?, What companies are using it and some Success Stories.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2tfQivhrpIM9D8yQVJLAtaLkGEcWdnKvk2TYszFoBIMiGFbHY4ghGKwEYfocBQmGi2G1HUt4GbCJEoh85MeIUvX_1wG4UI7ghMgx0u_oE85sdmQEKQAGljnXBfIX9VGcOrMR6kh9_xl4/s1600/Golang.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;img alt=&quot;Journey to Google&#39;s Go (Golang) Programming Tutorial Series&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2tfQivhrpIM9D8yQVJLAtaLkGEcWdnKvk2TYszFoBIMiGFbHY4ghGKwEYfocBQmGi2G1HUt4GbCJEoh85MeIUvX_1wG4UI7ghMgx0u_oE85sdmQEKQAGljnXBfIX9VGcOrMR6kh9_xl4/s1600/Golang.png&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;!--adsenseLink--&gt;

&lt;span style=&quot;font-family: inherit;&quot;&gt;What are the features of Go (Golang) ?&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Fast compilation, statically typed strict programming language&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Concurrent programming language&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Scalable to large systems&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Has good garbage collection&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Function can return multiple values&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Standardized by De facto&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Syntax is mostly similar to C family with some richness taken from python,c++,pascal etc&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;It is object oriented with methods &amp;amp; interfaces but without type inheritance like we have in Java&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;What is Golang good for ?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Go (Golang) is good for server-side applications to build high scalable web applications,It is also used for Machine learning, Natural language processing,Artificial Intelligence,Internet of Things,data visualization etc&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Should I learn Golang for building Web Applications ?&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;I would like to say &quot;Big YES&quot;, why ? Any web application that you going to build should have ability to handle good decent amount of traffic,should have good code readability,should utilize all available resources and moreover it should be efficient and fast to reduce your overall cost of the application. Agree with me ?&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;What companies are already using Go (Golang) in production ?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Google&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Dropbox&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Cloudflare&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Sendgrid&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;Soundcloud&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;What are some success stories of using Golang in production ?&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;background-color: white; box-sizing: border-box; margin-bottom: 16px; margin-top: 0px; padding-left: 2em;&quot;&gt;
&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;&lt;a href=&quot;http://www.quora.com/Go-programming-language/Is-Google-Go-ready-for-production-use/answer/Kunal-Anand&quot; rel=&quot;nofollow&quot; style=&quot;background-color: transparent; box-sizing: border-box; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: blue; font-family: inherit;&quot;&gt;Go at the BBC&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;&lt;a href=&quot;http://backstage.soundcloud.com/2012/07/go-at-soundcloud/&quot; rel=&quot;nofollow&quot; style=&quot;background-color: transparent; box-sizing: border-box; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: blue; font-family: inherit;&quot;&gt;Go at SoundCloud&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;&lt;a href=&quot;https://groups.google.com/forum/#!topic/golang-nuts/MeiTNnGhLg8/discussion&quot; rel=&quot;nofollow&quot; style=&quot;background-color: transparent; box-sizing: border-box; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: blue; font-family: inherit;&quot;&gt;Go at Moovweb&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;&lt;a href=&quot;http://blog.golang.org/2011/12/building-stathat-with-go.html&quot; rel=&quot;nofollow&quot; style=&quot;background-color: transparent; box-sizing: border-box; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: blue; font-family: inherit;&quot;&gt;Building StatHat with Go&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;&lt;a href=&quot;http://blog.cloudflare.com/go-at-cloudflare&quot; rel=&quot;nofollow&quot; style=&quot;background-color: transparent; box-sizing: border-box; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: blue; font-family: inherit;&quot;&gt;Go at CloudFlare&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;box-sizing: border-box; margin-top: 0.25em;&quot;&gt;&lt;span style=&quot;background-color: transparent; box-sizing: border-box; font-family: inherit; text-decoration: none;&quot;&gt;&lt;a href=&quot;http://www.mikespook.com/2012/08/why-you-php-guys-should-learn-golang/&quot; rel=&quot;nofollow&quot; style=&quot;background-color: transparent; box-sizing: border-box; color: blue; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;Why you PHP guys should learn Golang&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;What are some good IDE&#39;s or plugins to start with ?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;background-color: white; border: 0px; margin: 0px 0px 1em 30px; padding: 0px;&quot;&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 0.5em; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;color: #242729; font-family: inherit;&quot;&gt;Plugins for IDEs:&lt;/span&gt;&lt;ul style=&quot;border: 0px; list-style-type: disc; margin: 0px 0px 0px 30px; padding: 0.5em 0px 0px;&quot;&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 0.5em; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;color: #242729;&quot;&gt;IntelliJ:&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;a href=&quot;https://plugins.jetbrains.com/idea/plugin/5047-go-lang-plugin&quot; rel=&quot;nofollow noreferrer&quot; style=&quot;border: 0px; color: blue; cursor: pointer; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;go plugin&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://go-ide.com/&quot; rel=&quot;nofollow noreferrer&quot; style=&quot;border: 0px; color: blue; cursor: pointer; margin: 0px; padding: 0px; text-decoration: none;&quot;&gt;go-ide&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;color: #242729;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #242729;&quot;&gt;microsite&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 0.5em; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;color: #242729;&quot;&gt;Visual Studio:&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://github.com/Microsoft/vscode-go&quot; rel=&quot;nofollow noreferrer&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;vscode-go&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 0.5em; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;color: #242729;&quot;&gt;Eclipse:&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://goclipse.github.io/&quot; rel=&quot;nofollow noreferrer&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;goclipse&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;color: #242729;&quot;&gt;Netbeans:&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://plugins.netbeans.org/plugin/25606/go&quot; rel=&quot;nofollow noreferrer&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px; text-decoration: none;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Go plugin&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 0.5em; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;color: #242729; font-family: inherit;&quot;&gt;Text Editors that support Go or have plugins:&lt;/span&gt;&lt;ul style=&quot;border: 0px; list-style-type: disc; margin: 0px 0px 0px 30px; padding: 0.5em 0px 0px;&quot;&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 0.5em; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;color: #242729;&quot;&gt;Atom:&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://atom.io/packages/go-plus&quot; rel=&quot;nofollow noreferrer&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;go-plus&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 0.5em; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;color: #242729;&quot;&gt;Sublime Text:&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://github.com/DisposaBoy/GoSublime&quot; rel=&quot;nofollow noreferrer&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;GoSublime&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;a href=&quot;http://www.zeusedit.com/go.html&quot; rel=&quot;nofollow noreferrer&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: blue; font-family: inherit;&quot;&gt;Zeus&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 0.5em; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;color: #242729; font-family: inherit;&quot;&gt;Go-Specific IDEs:&lt;/span&gt;&lt;ul style=&quot;border: 0px; list-style-type: disc; margin: 0px 0px 0px 30px; padding: 0.5em 0px 0px;&quot;&gt;
&lt;li style=&quot;border: 0px; margin: 0px 0px 0.5em; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;a href=&quot;https://github.com/visualfc/liteide&quot; rel=&quot;nofollow noreferrer&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: blue; font-family: inherit;&quot;&gt;LiteIDE&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;border: 0px; margin: 0px; overflow-wrap: break-word; padding: 0px;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;color: #242729;&quot;&gt;IntelliJ&#39;s&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://www.jetbrains.com/go/&quot; rel=&quot;nofollow noreferrer&quot; style=&quot;border: 0px; cursor: pointer; margin: 0px; padding: 0px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Gogland&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #242729;&quot;&gt;&amp;nbsp;( Recommended)&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Lets take very basic Hello World Example in Go:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;pre&gt;
&lt;code class=&quot;go-html&quot;&gt;
package main

import &quot;fmt&quot;

func main() {
 fmt.Println(&quot;Hello World, Journey to Google&#39;s Go (Golang) Programming Tutorial Series &quot;)
}
&lt;/code&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;Output :&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background: rgb(255, 255, 216); border-radius: 0px; color: #222222; font-family: menlo, monospace; line-height: 1.4em; overflow-x: auto; padding: 0px;&quot;&gt;&lt;span class=&quot;stdout&quot;&gt;Hello World, Journey to Google&#39;s Go (Golang) Programming Tutorial Series &lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;So just to keep it simple and short, this is just an introduction to my golang tutorial series, In my coming post, we&#39;ll be seeing more of problem and its solution (Recipe or How-To) type tutorials using Go (Golang) programming language. Thanks and have a nice day&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codispatch.blogspot.com/feeds/7037544688526511096/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codispatch.blogspot.com/2017/01/journey-to-go-golang-programming.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/7037544688526511096'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/7037544688526511096'/><link rel='alternate' type='text/html' href='http://codispatch.blogspot.com/2017/01/journey-to-go-golang-programming.html' title='Journey to Google&amp;#39;s Go (Golang) Programming Tutorial Series '/><author><name>Shravan C</name><uri>http://www.blogger.com/profile/07299338851374232212</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCkZjKG4qB0Hm70obtBjJFRtEdxW5Ui5iLXXHLbn9yi4TA14dHwN1KSlHF_GHXYtdiBCbFEOxWk4XGHqETjHVLLmQILELFkKXZPa18lkQzbrN3vvvqYL7HsgyJcSmb/s113/download.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2tfQivhrpIM9D8yQVJLAtaLkGEcWdnKvk2TYszFoBIMiGFbHY4ghGKwEYfocBQmGi2G1HUt4GbCJEoh85MeIUvX_1wG4UI7ghMgx0u_oE85sdmQEKQAGljnXBfIX9VGcOrMR6kh9_xl4/s72-c/Golang.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8083898279613891327.post-7546907043167526536</id><published>2016-03-11T18:51:00.002+05:30</published><updated>2020-05-25T20:00:08.482+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Java Program to Implement Breadth First Search (BFS)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;!--adsense--&gt;
&lt;b style=&quot;background-color: white; color: #252525; font-family: sans-serif; line-height: 22.4px;&quot;&gt;Breadth-first search&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #252525; font-family: sans-serif; line-height: 22.4px;&quot;&gt;&amp;nbsp;(&lt;/span&gt;&lt;b style=&quot;background-color: white; color: #252525; font-family: sans-serif; line-height: 22.4px;&quot;&gt;BFS&lt;/b&gt;&lt;span style=&quot;background-color: white; color: #252525; font-family: sans-serif; line-height: 22.4px;&quot;&gt;) is an algorithm for searching or traversing the tree or graph.BFS algorithm was invented by E.F. Moore in the late 1950s.&lt;/span&gt;&lt;span style=&quot;color: #252525; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;line-height: 22.4px;&quot;&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Breadth-first_search&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Breadth First Search (BFS) Algorithm in detail&lt;/a&gt;&amp;nbsp;.It is Similar to DFS Algorithm but we are using single source and traversing all possible vertices from that single source breadth wise .We have used cal_BFS() to check whether we can traverse or not . If yes print them if not just add them to the stack or queue . Remove each element from stack then check if any remaining elements is having direct path from source node. if yes print them if not add them to other stack or queue .Finally print all remaining nodes from the stack or queue.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #252525; font-family: sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 14px; line-height: 22.4px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6h4E3wq1PWlwY25iBagEhUww59ZIsXo1r_jJlNTs3aR4IHiXaTWu99ZTwnSI5wumLoOlmxSN_kY_BoCdJG-cDxjCNMvL1jhyFelkI_puf_Xx7PP9e23bfieV9XoIcQaA8yq-VPMYqXzQ/s1600/Java+Program+to+Implement+Breadth+First+Search+Algorithm.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Java Program to Implement Breadth First Search (BFS)&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6h4E3wq1PWlwY25iBagEhUww59ZIsXo1r_jJlNTs3aR4IHiXaTWu99ZTwnSI5wumLoOlmxSN_kY_BoCdJG-cDxjCNMvL1jhyFelkI_puf_Xx7PP9e23bfieV9XoIcQaA8yq-VPMYqXzQ/s1600/Java+Program+to+Implement+Breadth+First+Search+Algorithm.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;!--adsenselink--&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
Let us take a sample example for Breadth-first Search (BFS) Algorithm.&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe-42NVefTQh0Y7joKXjvtAdo4jhEB6_egzuEPr_PbdgGDpgxbWC8yCUOFdXTHiFpBPEKcNGMGSfDPWchddQakPNve3sKitlfs47G4vHDRNV2oZ_V2Hq4YaY-fZG4beCmG1ftw6kvK5ww/s1600/bfs.png&quot;&gt;&lt;img alt=&quot;Java Program to Implement Breadth First Search Algorithm&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhe-42NVefTQh0Y7joKXjvtAdo4jhEB6_egzuEPr_PbdgGDpgxbWC8yCUOFdXTHiFpBPEKcNGMGSfDPWchddQakPNve3sKitlfs47G4vHDRNV2oZ_V2Hq4YaY-fZG4beCmG1ftw6kvK5ww/s400/bfs.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;java-html&quot;&gt;
import java.util.*;
public class BFS 
{
 public boolean visited[] = new boolean[50];
 public int q[] = new int[50];
 public int m[][] =new int[50][50];
 public int nodes;
 
 public void calc_BFS(int source)
 {
  int i,r=-1,f=0;
  for(i=1;i&amp;lt;=nodes;i++)
   if(m[source][i]&amp;gt;0 &amp;amp;&amp;amp; !visited[i])
    q[++r]=i;
  if(f&amp;lt;=r)
  {
   visited[q[f]]=true;
   calc_BFS(q[f++]);
  } 
 }
 
public static void main(String args[])
 {
  int source,i,j,k=1;
  int stack[]=new int[10];
  int s[]=new int[10];
  BFS b = new BFS();
  Scanner in = new Scanner(System.in);
  System.out.println(&quot;Enter the Number of Nodes \n&quot;);
  b.nodes = in.nextInt();
  
    for(i=1;i&amp;lt;=b.nodes;i++)
    {
            b.visited[i]=false;
   b.q[i]=0; 
    }
   System.out.println(&quot;Enter the Weights for \t&quot;+b.nodes+&quot;Nodes Below \n&quot;);
 for(i=1;i&amp;lt;=b.nodes;i++)
   for(j=1;j&amp;lt;=b.nodes;j++) 
   {
   System.out.println(&quot;Enter the Weights for \t&quot;+i+&quot;th row \t&quot;+j+&quot;th Column :&quot;);
   b.m[i][j] = in.nextInt();
   }
  System.out.println(&quot;Enter the Source Vertex :\n&quot;);
  source=in.nextInt();
  // Calculate the BFS
  b.calc_BFS(source);
  // Display nodes that are directly reachable from source 
  System.out.println(&quot;The Nodes that can be reachable from \t&quot;+source+&quot;\t to all other vertices are : \n&quot;);
        for(i=1;i&amp;lt;=b.nodes;i++)
          if(b.visited[i])
   System.out.print(&quot;\t&quot;+i+&quot;\t&quot;);
    else
    { 
   stack[k++]=i;
    }
     // pop out the remaining elements from the stack which are directly reachable from source
    k=k-1;j=1;
    int ele,f=0;
    while(k&amp;gt;0)
    {
     //get element from stack and check if there is any direct path from source to that element 
     ele=stack[k--];
     for(i=1;i&amp;lt;=b.nodes;i++)
     {
      if(ele==i &amp;amp;&amp;amp; b.m[1][i]==1)
      {
       System.out.print(&quot;\t&quot;+ele+&quot;\t&quot;);
       f=1;
       break;
      } 
      else
       f=0;
     } 
     // if no direct path from source ,collect them and store it in array S .
     if(f==0)
      s[j++]=ele;
     
    }
    k=j-1;
    j=1;
    // pop out the remaining elements from the stack even though they are not reachable directly from source
    while(j&amp;lt;=k)
    {
     System.out.print(&quot;\t&quot;+s[j++]+&quot;\t&quot;);
    }   
 } 
}
&lt;/code&gt;
&lt;/pre&gt;
&lt;span style=&quot;color: red;&quot;&gt;Please Click and Drag from the beginning to End of the above Source code for Selection and Copying.
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Adjacency Matrix representation:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; a b c d e f&lt;br /&gt;
a &amp;nbsp;0 0 1 1 1 0&lt;br /&gt;
b &amp;nbsp;0 0 0 0 1 1&lt;br /&gt;
c &amp;nbsp;1 0 0 1 0 1&lt;br /&gt;
d &amp;nbsp;1 0 1 0 0 0&lt;br /&gt;
e &amp;nbsp;1 1 0 0 0 1&lt;br /&gt;
f &amp;nbsp;0 1 1 0 1 0&lt;br /&gt;
&lt;br /&gt;
Sample Output for the above graph is :&lt;br /&gt;
&lt;br /&gt;
javac BFS.java&lt;br /&gt;
java BFS&lt;br /&gt;
&lt;br /&gt;
Enter the Number of Nodes : 6&lt;br /&gt;
Enter the Weights for &amp;nbsp; 6 Nodes Below :&lt;br /&gt;
&lt;br /&gt;
Enter the Weights for &amp;nbsp; 1th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1th Column : 0&lt;br /&gt;
Enter the Weights for &amp;nbsp; 1th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2th Column : 0&lt;br /&gt;
Enter the Weights for &amp;nbsp; 1th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3th Column : 1&lt;br /&gt;
Enter the Weights for &amp;nbsp; 1th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4th Column : 1&lt;br /&gt;
Enter the Weights for &amp;nbsp; 1th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5th Column : 1&lt;br /&gt;
Enter the Weights for &amp;nbsp; 1th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6th Column : 0&lt;br /&gt;
&lt;br /&gt;
Enter the Weights for &amp;nbsp; 2th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1th Column : 0&lt;br /&gt;
Enter the Weights for &amp;nbsp; 2th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2th Column : 0&lt;br /&gt;
Enter the Weights for &amp;nbsp; 2th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3th Column : 0&lt;br /&gt;
Enter the Weights for &amp;nbsp; 2th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4th Column : 0&lt;br /&gt;
Enter the Weights for &amp;nbsp; 2th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5th Column : 1&lt;br /&gt;
Enter the Weights for &amp;nbsp; 2th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6th Column : 1&lt;br /&gt;
&lt;br /&gt;
Enter the Weights for &amp;nbsp; 3th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1th Column : 1&lt;br /&gt;
Enter the Weights for &amp;nbsp; 3th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2th Column : 0&lt;br /&gt;
Enter the Weights for &amp;nbsp; 3th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3th Column : 0&lt;br /&gt;
Enter the Weights for &amp;nbsp; 3th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4th Column : 1&lt;br /&gt;
Enter the Weights for &amp;nbsp; 3th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5th Column : 0&lt;br /&gt;
Enter the Weights for &amp;nbsp; 3th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6th Column : 1&lt;br /&gt;
&lt;br /&gt;
Enter the Weights for &amp;nbsp; 4th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1th Column : 1&lt;br /&gt;
Enter the Weights for &amp;nbsp; 4th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2th Column : 0&lt;br /&gt;
Enter the Weights for &amp;nbsp; 4th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3th Column : 1&lt;br /&gt;
Enter the Weights for &amp;nbsp; 4th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4th Column : 0&lt;br /&gt;
Enter the Weights for &amp;nbsp; 4th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5th Column : 0&lt;br /&gt;
Enter the Weights for &amp;nbsp; 4th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6th Column : 0&lt;br /&gt;
&lt;br /&gt;
Enter the Weights for &amp;nbsp; 5th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1th Column : 1&lt;br /&gt;
Enter the Weights for &amp;nbsp; 5th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2th Column : 1&lt;br /&gt;
Enter the Weights for &amp;nbsp; 5th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3th Column : 0&lt;br /&gt;
Enter the Weights for &amp;nbsp; 5th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4th Column : 0&lt;br /&gt;
Enter the Weights for &amp;nbsp; 5th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5th Column : 0&lt;br /&gt;
Enter the Weights for &amp;nbsp; 5th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6th Column : 1&lt;br /&gt;
&lt;br /&gt;
Enter the Weights for &amp;nbsp; 6th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1th Column : 0&lt;br /&gt;
Enter the Weights for &amp;nbsp; 6th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2th Column : 1&lt;br /&gt;
Enter the Weights for &amp;nbsp; 6th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3th Column : 1&lt;br /&gt;
Enter the Weights for &amp;nbsp; 6th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4th Column : 0&lt;br /&gt;
Enter the Weights for &amp;nbsp; 6th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5th Column : 1&lt;br /&gt;
Enter the Weights for &amp;nbsp; 6th row &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6th Column : 0&lt;br /&gt;
&lt;br /&gt;
Enter the Source Vertex : 1&lt;br /&gt;
&lt;br /&gt;
The Nodes that can be reachable from &amp;nbsp; &amp;nbsp;1 &amp;nbsp; to all other vertices are :&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you have any Comments please let me know . Enjoy Coding .&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Also Read :&amp;nbsp;&lt;/b&gt; 
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;a class=&quot;PXLWASD-F-i&quot; href=&quot;http://www.codispatch.blogspot.com/2015/12/java-program-implement-google-page-rank-algorithm.html&quot; style=&quot;border: 0px; color: #1155cc; display: inline-block; font-family: Arial, Helvetica, sans-serif; margin: 0px 10px 0px 0px; max-width: 100%; overflow: hidden; padding: 0px; text-decoration: none; text-overflow: ellipsis; vertical-align: baseline; white-space: nowrap; width: auto;&quot; target=&quot;_blank&quot;&gt;Java Program to Implement Simple PageRank Algorithm&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codispatch.blogspot.com/feeds/7546907043167526536/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codispatch.blogspot.com/2016/03/java-program-implement-breadth-first-search-bfs-algorithm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/7546907043167526536'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/7546907043167526536'/><link rel='alternate' type='text/html' href='http://codispatch.blogspot.com/2016/03/java-program-implement-breadth-first-search-bfs-algorithm.html' title='Java Program to Implement Breadth First Search (BFS)'/><author><name>Shravan C</name><uri>http://www.blogger.com/profile/07299338851374232212</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCkZjKG4qB0Hm70obtBjJFRtEdxW5Ui5iLXXHLbn9yi4TA14dHwN1KSlHF_GHXYtdiBCbFEOxWk4XGHqETjHVLLmQILELFkKXZPa18lkQzbrN3vvvqYL7HsgyJcSmb/s113/download.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6h4E3wq1PWlwY25iBagEhUww59ZIsXo1r_jJlNTs3aR4IHiXaTWu99ZTwnSI5wumLoOlmxSN_kY_BoCdJG-cDxjCNMvL1jhyFelkI_puf_Xx7PP9e23bfieV9XoIcQaA8yq-VPMYqXzQ/s72-c/Java+Program+to+Implement+Breadth+First+Search+Algorithm.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8083898279613891327.post-2394167479089208472</id><published>2016-02-28T21:42:00.002+05:30</published><updated>2020-05-25T20:27:10.708+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>How to Create Simple Notepad with Save &amp; Clear Option | PHP </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;!--adsense--&gt;
To create a simple Notepad Application using PHP we need 3 main things : Connect page, Index page and Save page . The Connect page is used to create connection to your backend database .The Index page is used to interact with the front end user and the Save page actually saves your content or put your text content from front end Notepad to backend database . We will also use AJAX and Jquery for displaying the instant error messages .&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDlZhVvEfqvC6CHLAj56q9gEdpiDJ5LY6wgXsMlPVr-bfv5Irp1fj0gJc88OrglImzRGboNKarvYC3tAn9TmMlL06I98FBdJZzn3pQCBdomoK82g2YvPrKGogwqrXRu-iPzMreG3RLQXE/s1600/TextFile.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;How to Create Simple Notepad with Save &amp;amp; Clear Option | PHP&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDlZhVvEfqvC6CHLAj56q9gEdpiDJ5LY6wgXsMlPVr-bfv5Irp1fj0gJc88OrglImzRGboNKarvYC3tAn9TmMlL06I98FBdJZzn3pQCBdomoK82g2YvPrKGogwqrXRu-iPzMreG3RLQXE/s1600/TextFile.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;!--adsenselink--&gt;
&lt;br /&gt;
&lt;center&gt;
&lt;a class=&quot;dd&quot; href=&quot;http://codispatch.co.nf/demos/notepad/index.php&quot; target=&quot;_blank&quot;&gt;View demo &lt;i class=&quot;fa fa-external-link&quot;&gt;&lt;/i&gt;&lt;/a&gt;&amp;nbsp; 
&lt;a class=&quot;dd&quot; href=&quot;https://github.com/Codispatch/NotePad&quot; target=&quot;_blank&quot;&gt;&lt;i class=&quot;fa fa-github-square&quot;&gt;&lt;/i&gt; Find this Project on Github &lt;i class=&quot;fa fa-external-link&quot;&gt;&lt;/i&gt;&lt;/a&gt;&lt;/center&gt;
&lt;br /&gt;


&lt;b&gt;Connect.php&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
&lt;code class=&quot;php-html&quot;&gt;
&amp;lt;?php
$HOST=&#39;localhost&#39;;
$USERNAME =&#39;root&#39;;
$PASSWORD=&#39;&#39;;
$DATABASE=&#39;notepad&#39;;

// Create connection
$connection = new mysqli($HOST, $USERNAME,$PASSWORD,$DATABASE);

// Check connection
if ($connection-&amp;gt;connect_error) {
    die(&quot;Connection failed: &quot;.$connection-&amp;gt;connect_error);
} 

?&amp;gt;
&lt;/code&gt;
&lt;/pre&gt;
&lt;br /&gt;
The host in this example is Local Host but you can change this and point to your custom domain address.&lt;br /&gt;
Username and Password are used to get access to the MYSQL database .&lt;br /&gt;
I have used notepad as name of the MySQL Database .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Index.php&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;php-html&quot;&gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot; src=&quot;jquery.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
    $(function() {
  $(&quot;#save&quot;).click(function() {
  var filename = $(&quot;#filename&quot;).val();
  var textarea = $(&quot;#textarea&quot;).val();
  var formdata = &#39;filename=&#39;+ filename + &#39;&amp;amp;textarea=&#39; + textarea;

if(filename==&#39;&#39; || textarea==&#39;&#39;)
{
  $(&#39;.onfailure&#39;).fadeIn(&quot;fast&quot;).delay(2000).fadeOut(&quot;fast&quot;);
}
else
{
   $.ajax({
    type: &quot;POST&quot;,
    url: &quot;save.php&quot;,
    data: formdata,
    success: function(){
    $(&#39;.onsuccess&#39;).fadeIn(&quot;fast&quot;).delay(2000).fadeOut(&quot;fast&quot;);
    }
  });
}
return false;
});
});
function eraseText() {
    document.getElementById(&quot;textarea&quot;).value = &quot;&quot;;
 $(&#39;.onclear&#39;).fadeIn(&quot;fast&quot;).delay(2000).fadeOut(&quot;fast&quot;);
}
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;
&amp;lt;style&amp;gt;
#outer-wrapper {
  padding:0px 50px;
}
#inner-wrapper {
 padding: 50px 0px 20px 0px;
}
#options {
 padding:20px 0px 20px 0px;
}
#status span{
 padding:20px 0px 20px 50px;
}
&amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;div id=&quot;outer-wrapper&quot;&amp;gt;
&amp;lt;form id=&quot;notepad&quot; &amp;gt;
&amp;lt;div id=&quot;inner-wrapper&quot;&amp;gt;&amp;lt;input type=&quot;text&quot; id=&quot;filename&quot; name=&quot;filename&quot; placeholder=&quot;Enter your Filename ...&quot; value=&quot;&quot; &amp;gt;.txt&amp;lt;/input&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;textarea id=&quot;textarea&quot; rows=&quot;20&quot; cols=&quot;100&quot; name=&quot;textarea&quot; placeholder=&quot;Type your text here ...&quot; value=&quot;&quot; &amp;gt;&amp;lt;/textarea&amp;gt;
&amp;lt;/form&amp;gt;
&amp;lt;div id=&quot;options&quot;&amp;gt;
&amp;lt;input type=&quot;button&quot; id=&quot;save&quot; name=&quot;save&quot;  value=&quot;Save the file &quot; &amp;gt;&amp;lt;/input&amp;gt; | &amp;lt;input type=&quot;button&quot; id=&quot;clear&quot; onclick=&quot;javascript:eraseText();&quot; value=&quot;Clear&quot;&amp;gt;&amp;lt;/input&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;div id=&quot;status&quot;&amp;gt;
&amp;lt;span class=&quot;onsuccess&quot; style=&quot;display:none&quot;&amp;gt; File has been Saved Successfully. &amp;lt;/span&amp;gt;
&amp;lt;span class=&quot;onfailure&quot; style=&quot;display:none&quot;&amp;gt; Text Area or Filename cannot be left Blank.  &amp;lt;/span&amp;gt;
&amp;lt;span class=&quot;onclear&quot; style=&quot;display:none&quot;&amp;gt; Text Area has been Cleared.  &amp;lt;/span&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
I have used Jquery On Click function.So On click of Save button ,get the filename and Text Area value and store it in 2 variables.Then validate these two data (check if it is empty) , if it is empty display error message using Jquery fadeIn() and&amp;nbsp;fadeOut()&lt;span style=&quot;font-family: monospace;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;function or else use AJAX post request to send the form data to Save.php . Dont forget to add or link to Jquery library file.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Save.php&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code class=&quot;php-html&quot;&gt;
&amp;lt;?php
include(&#39;connect.php&#39;);
$filename=&quot;&quot;;
$textarea=&quot;&quot;;
if($_POST)
{
$filename=$_POST[&#39;filename&#39;].&quot;.txt&quot;;
$filename = str_replace(&#39; &#39;, &#39;_&#39;,$filename);
$textarea=$_POST[&#39;textarea&#39;];
$query = &quot;update notepad_table set filename=&#39;&quot;.$filename.&quot;&#39;,textarea=&#39;&quot;.$textarea.&quot;&#39; where id=1 ;&quot;;
$result = mysqli_query($connection,$query);
}else { }

?&amp;gt;
&lt;/code&gt;
&lt;/pre&gt;
&lt;br /&gt;
Get the Filename and Text Area from Index.php,Store it in 2 variables and finally update the MYSQL Database notepad table using Connect.php connection.All Done .Any Questions Please comment below.&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Also Read :&amp;nbsp;&lt;/b&gt; 
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;a class=&quot;PXLWASD-F-i&quot; href=&quot;http://www.codispatch.blogspot.com/2015/12/java-program-implement-google-page-rank-algorithm.html&quot; style=&quot;border: 0px; color: #1155cc; display: inline-block; font-family: Arial, Helvetica, sans-serif; margin: 0px 10px 0px 0px; max-width: 100%; overflow: hidden; padding: 0px; text-decoration: none; text-overflow: ellipsis; vertical-align: baseline; white-space: nowrap; width: auto;&quot; target=&quot;_blank&quot;&gt;Java Program to Implement Simple PageRank Algorithm&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codispatch.blogspot.com/feeds/2394167479089208472/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codispatch.blogspot.com/2016/02/PHP-simple-online-notepad-with-save-clear-options.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/2394167479089208472'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/2394167479089208472'/><link rel='alternate' type='text/html' href='http://codispatch.blogspot.com/2016/02/PHP-simple-online-notepad-with-save-clear-options.html' title='How to Create Simple Notepad with Save &amp; Clear Option | PHP '/><author><name>Shravan C</name><uri>http://www.blogger.com/profile/07299338851374232212</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCkZjKG4qB0Hm70obtBjJFRtEdxW5Ui5iLXXHLbn9yi4TA14dHwN1KSlHF_GHXYtdiBCbFEOxWk4XGHqETjHVLLmQILELFkKXZPa18lkQzbrN3vvvqYL7HsgyJcSmb/s113/download.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDlZhVvEfqvC6CHLAj56q9gEdpiDJ5LY6wgXsMlPVr-bfv5Irp1fj0gJc88OrglImzRGboNKarvYC3tAn9TmMlL06I98FBdJZzn3pQCBdomoK82g2YvPrKGogwqrXRu-iPzMreG3RLQXE/s72-c/TextFile.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8083898279613891327.post-6176416366881503735</id><published>2015-12-14T15:57:00.003+05:30</published><updated>2020-05-25T19:06:14.297+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Java Program to Implement Simple PageRank Algorithm </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;!--adsense--&gt;
When you go and type some keywords in Google Search Engine a list of Web Pages will be displayed ,but how does the search engine know which page to be shown first to the user ? To solve this problem a &amp;nbsp;algorithm called PageRank was developed at Stanford university by Larry Page and Sergey Brin in 1996.The PageRank Algorithm uses probabilistic distribution to calculate rank of a Web page and using this rank display the search results to the user. The Pagerank is recalculated every time &amp;nbsp;the search engine crawls the web.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjThzQzl97M3Wt3tfV7XA62TaO0AmsVBDCboMw4gCIcDRNpveu6BzZkR0QG5SXxkav6asyQHhcFyy_GP7IFJUHG92IBljmBMXnGb6kfEQZ4K5kVaKD9Bjl9Ivn-XBLWcBei6XNe_8GANfE/s1600/Java+Program+to+Implement+Simple+PageRank+Algorithm1.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Java Program to Implement Simple PageRank Algorithm&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjThzQzl97M3Wt3tfV7XA62TaO0AmsVBDCboMw4gCIcDRNpveu6BzZkR0QG5SXxkav6asyQHhcFyy_GP7IFJUHG92IBljmBMXnGb6kfEQZ4K5kVaKD9Bjl9Ivn-XBLWcBei6XNe_8GANfE/s1600/Java+Program+to+Implement+Simple+PageRank+Algorithm1.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;!--adsenselink--&gt;

The original Page Rank algorithm which was described by Larry Page and Sergey Brin is :&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;PR(A) = (1-d) + d (PR(W1)/C(W1) + ... + PR(Wn)/C(Wn))&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Where :&lt;br /&gt;
PR(A) – Page Rank of page A&lt;br /&gt;
PR(Wi) – Page Rank of pages Wi which link to page A&lt;br /&gt;
C(Wi) - number of outbound links on page Wi&lt;br /&gt;
d - damping factor which can be set between 0 and 1&lt;br /&gt;
&lt;br /&gt;
To calculate PageRank for the n Webpages ,First we initialise all Webpages with equal page rank of 1/n each.Then Step by Step we calculate Page Rank for each Webpage one after the other.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let us take one example :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhliByQdZf0jJ3KW5yFTcOQT3dk4z-ZYK-6XGsFNW3Fw_XgaesLsoU6rZilyrbBoAppyZqYaXCX76oqO_FunL85mZ9fH-3A0NgwNQ8t1m9L8B8o77CcqMo_veiSa2Xml6dJ39841klpbqE/s1600/Java+Program+to+Implement+Simple+PageRank+Algorithm.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Java Program to Implement Simple PageRank Algorithm&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhliByQdZf0jJ3KW5yFTcOQT3dk4z-ZYK-6XGsFNW3Fw_XgaesLsoU6rZilyrbBoAppyZqYaXCX76oqO_FunL85mZ9fH-3A0NgwNQ8t1m9L8B8o77CcqMo_veiSa2Xml6dJ39841klpbqE/s1600/Java+Program+to+Implement+Simple+PageRank+Algorithm.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;There are 5 Web pages represented by Nodes A, B, C , D, E .The hyperlink from each webpage to the other is represented by the arrow head.&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikfL14eBXBkxd_79wV7tIM3AjJMVSVnoYe4skx-tEBOw331F1Dq-cagwbLUwlkrCPy1excWFHzSSM1BncwAqqZ4fUVCk9OxbjO8u6FuSWH3pW2czTLW427jdCk69AW72HarzwedYXu7GQ/s1600/PageRank+Values.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Java Program to Implement Simple PageRank Algorithm&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikfL14eBXBkxd_79wV7tIM3AjJMVSVnoYe4skx-tEBOw331F1Dq-cagwbLUwlkrCPy1excWFHzSSM1BncwAqqZ4fUVCk9OxbjO8u6FuSWH3pW2czTLW427jdCk69AW72HarzwedYXu7GQ/s1600/PageRank+Values.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;At 0th Step we have all Webpages PageRank values 0.2 that is 1/5 (1/n) . To get PageRank of Webpage A ,consider all the incoming links to A .So we have 1/4th the Page Rank of C is pointed to A. So it will be (1/5)*(1/4) which is (1/20) or 0.05 the Page Rank of A.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Similarly the Page Rank of B will be &amp;nbsp;(1/5)*(1/4)+(1/5)*(1/1)&amp;nbsp;which is (5/20) or 0.25 because A&#39;s PageRank value is 1/5 or 0.2 from Step 0 . Even though we got 0.05 of A&#39;s PageRank&amp;nbsp;in Step 1&amp;nbsp;we are considering 0.05 when we are Calculating Page Rank of B in Step 2.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The general rule is --&amp;gt; we consider (N-1)th step values when we are calculating the Page Rank values for Nth Step . Not Clear ? Please Comment it below .&lt;br /&gt;
&lt;br /&gt;
In Similar way we calculate all the Page Rank Values and Sort them to Get the Most important Webpage to be displayed in the Search Results .&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8gzFRFGDQAw6NColkiuflSsXnjBQ320oL50_sEMkVKcT9_p0lu9IaTKx0xa8FBgHMD9gDj0N4PNlYeoKu7HBcCl2IiNC1cUuwAjw2bAg7BEwDdA8NCOLq4J542o5cm2P00HMt_0EudY0/s1600/PageRankTable.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img alt=&quot;Java Program to Implement Simple PageRank Algorithm&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8gzFRFGDQAw6NColkiuflSsXnjBQ320oL50_sEMkVKcT9_p0lu9IaTKx0xa8FBgHMD9gDj0N4PNlYeoKu7HBcCl2IiNC1cUuwAjw2bAg7BEwDdA8NCOLq4J542o5cm2P00HMt_0EudY0/s1600/PageRankTable.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Edith Law - lecture12&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
Java Code for Page Rank Algorithm :&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;pre&gt;&lt;code class=&quot;language-java&quot;&gt;
import java.util.*;
import java.io.*;
public class PageRank {

 public int path[][] = new int[10][10];
 public double pagerank[] = new double[10];

 public void calc(double totalNodes) {

  double InitialPageRank;
  double OutgoingLinks = 0;
  double DampingFactor = 0.85;
  double TempPageRank[] = new double[10];
  int ExternalNodeNumber;
  int InternalNodeNumber;
  int k = 1; // For Traversing
  int ITERATION_STEP = 1;
  InitialPageRank = 1 / totalNodes;
  System.out.printf(&quot; Total Number of Nodes :&quot; + totalNodes + &quot;\t Initial PageRank  of All Nodes :&quot; + InitialPageRank + &quot;\n&quot;);

  // 0th ITERATION  _ OR _ INITIALIZATION PHASE //
  
  for (k = 1; k &amp;lt;= totalNodes; k++) {
   this.pagerank[k] = InitialPageRank;
  }

  System.out.printf(&quot;\n Initial PageRank Values , 0th Step \n&quot;);
  for (k = 1; k &amp;lt;= totalNodes; k++) {
   System.out.printf(&quot; Page Rank of &quot; + k + &quot; is :\t&quot; + this.pagerank[k] + &quot;\n&quot;);
  }

  while (ITERATION_STEP &amp;lt;= 2) // Iterations
  {
   // Store the PageRank for All Nodes in Temporary Array 
   for (k = 1; k &amp;lt;= totalNodes; k++) {
    TempPageRank[k] = this.pagerank[k];
    this.pagerank[k] = 0;
   }

   for (InternalNodeNumber = 1; InternalNodeNumber &amp;lt;= totalNodes; InternalNodeNumber++) {
    for (ExternalNodeNumber = 1; ExternalNodeNumber &amp;lt;= totalNodes; ExternalNodeNumber++) {
     if (this.path[ExternalNodeNumber][InternalNodeNumber] == 1) {
      k = 1;
      OutgoingLinks = 0; // Count the Number of Outgoing Links for each ExternalNodeNumber
      while (k &amp;lt;= totalNodes) {
       if (this.path[ExternalNodeNumber][k] == 1) {
        OutgoingLinks = OutgoingLinks + 1; // Counter for Outgoing Links
       }
       k = k + 1;
      }
      // Calculate PageRank     
      this.pagerank[InternalNodeNumber] += TempPageRank[ExternalNodeNumber] * (1 / OutgoingLinks);
     }
    }
   }

   System.out.printf(&quot;\n After &quot; + ITERATION_STEP + &quot;th Step \n&quot;);

   for (k = 1; k &amp;lt;= totalNodes; k++)
    System.out.printf(&quot; Page Rank of &quot; + k + &quot; is :\t&quot; + this.pagerank[k] + &quot;\n&quot;);

   ITERATION_STEP = ITERATION_STEP + 1;
  }
  // Add the Damping Factor to PageRank
  for (k = 1; k &amp;lt;= totalNodes; k++) {
   this.pagerank[k] = (1 - DampingFactor) + DampingFactor * this.pagerank[k];
  }

  // Display PageRank
  System.out.printf(&quot;\n Final Page Rank : \n&quot;);
  for (k = 1; k &amp;lt;= totalNodes; k++) {
   System.out.printf(&quot; Page Rank of &quot; + k + &quot; is :\t&quot; + this.pagerank[k] + &quot;\n&quot;);
  }

 }
 
 public static void main(String args[]) {
  int nodes, i, j, cost;
  Scanner in = new Scanner(System.in);
  System.out.println(&quot;Enter the Number of WebPages \n&quot;);
  nodes = in .nextInt();
  PageRank p = new PageRank();
  System.out.println(&quot;Enter the Adjacency Matrix with 1-&amp;gt;PATH &amp;amp; 0-&amp;gt;NO PATH Between two WebPages: \n&quot;);
  for (i = 1; i &amp;lt;= nodes; i++)
   for (j = 1; j &amp;lt;= nodes; j++) {
    p.path[i][j] = in .nextInt();
    if (j == i)
     p.path[i][j] = 0;
   }
  p.calc(nodes);

 }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;span style=&quot;color: red;&quot;&gt;Please Click and Drag from the beginning to End of the above Source code for Selection and Copying.&lt;/span&gt;&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
To Compile and Run for above Example:&lt;/h4&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;javac PageRank.java&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;java PageRank&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Enter the Number of WebPages : 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Enter the Adjacency Matrix with 1-&amp;gt;PATH &amp;amp; 0-&amp;gt;NO PATH Between two WebPages:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;0 1 0 0 0&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;0 0 0 0 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;1 1 0 1 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;0 0 1 0 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;0 0 0 1 0&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Total Number of Nodes :5.0 &amp;nbsp; &amp;nbsp; &amp;nbsp;Initial PageRank &amp;nbsp;of All Nodes :0.2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Initial PageRank Values , 0th Step&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 1 is : &amp;nbsp; &amp;nbsp;0.2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 2 is : &amp;nbsp; &amp;nbsp;0.2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 3 is : &amp;nbsp; &amp;nbsp;0.2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 4 is : &amp;nbsp; &amp;nbsp;0.2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 5 is : &amp;nbsp; &amp;nbsp;0.2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;After 1th Step&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 1 is : &amp;nbsp; &amp;nbsp;0.05&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 2 is : &amp;nbsp; &amp;nbsp;0.25&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 3 is : &amp;nbsp; &amp;nbsp;0.1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 4 is : &amp;nbsp; &amp;nbsp;0.25&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 5 is : &amp;nbsp; &amp;nbsp;0.35&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;After 2th Step&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 1 is : &amp;nbsp; &amp;nbsp;0.025&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 2 is : &amp;nbsp; &amp;nbsp;0.07500000000000001&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 3 is : &amp;nbsp; &amp;nbsp;0.125&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 4 is : &amp;nbsp; &amp;nbsp;0.375&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 5 is : &amp;nbsp; &amp;nbsp;0.4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Final Page Rank &amp;nbsp;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 1 is : &amp;nbsp; &amp;nbsp;0.17125&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 2 is : &amp;nbsp; &amp;nbsp;0.21375000000000002&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 3 is : &amp;nbsp; &amp;nbsp;0.25625000000000003&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 4 is : &amp;nbsp; &amp;nbsp;0.46875&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;Page Rank of 5 is : &amp;nbsp; &amp;nbsp;0.49000000000000005&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Note:&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Final Page Rank Includes Damping Factor of 0.85 which is usually set between 0 and 1.&lt;/li&gt;
&lt;li&gt;InternalNodeNumber represents the Node which you are currently calculating its PageRank.&lt;/li&gt;
&lt;li&gt;ExternalNodeNumber represents the Nodes Other than InternalNodeNumber.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;For every InternalNodeNumber check if there is any Incoming Links from ExternalNodeNumber if No - Ignore and move to next ExternalNodeNumber,If Yes - Count all the OutgoingLinks for that ExternalNodeNumber.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Finally Calculate Pagerank :&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;PR(InternalNodeNumber) +=&amp;nbsp;PR(ExternalNodeNumber)/All OutgoingLinks for ExternalNodeNumber&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;So from the above values , We have Webpage A(1) is the most important Page , Webpage B(2) and C(3) have almost equal importance with B(2) slightly more importance ,Webpage D(4) has some importance and Webpage E(5) has least importance.This helps to Rank Webpages in the Search results.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Please Note: Actual google Page rank Algorithm for large network of webpages grows logarithmic and slightly different from the one above. This Page Rank algorithm is fully owned by google inc and I just illustrated with a help of a Java Program to implement this Algorithm .I hope you enjoyed this .Thanks Have Nice Day.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Update1: New Example has been Added and Images are Updated.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Update2: I have Considered Damping Factor in my Implementation which is set to 0.85.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Update3:&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;while(u&amp;lt;=2) Changed to &lt;/span&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;while(ITERATION_STEP&amp;lt;=2).&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;!--adsense--&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codispatch.blogspot.com/feeds/6176416366881503735/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codispatch.blogspot.com/2015/12/java-program-implement-google-page-rank-algorithm.html#comment-form' title='16 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/6176416366881503735'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/6176416366881503735'/><link rel='alternate' type='text/html' href='http://codispatch.blogspot.com/2015/12/java-program-implement-google-page-rank-algorithm.html' title='Java Program to Implement Simple PageRank Algorithm '/><author><name>Shravan C</name><uri>http://www.blogger.com/profile/07299338851374232212</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCkZjKG4qB0Hm70obtBjJFRtEdxW5Ui5iLXXHLbn9yi4TA14dHwN1KSlHF_GHXYtdiBCbFEOxWk4XGHqETjHVLLmQILELFkKXZPa18lkQzbrN3vvvqYL7HsgyJcSmb/s113/download.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjThzQzl97M3Wt3tfV7XA62TaO0AmsVBDCboMw4gCIcDRNpveu6BzZkR0QG5SXxkav6asyQHhcFyy_GP7IFJUHG92IBljmBMXnGb6kfEQZ4K5kVaKD9Bjl9Ivn-XBLWcBei6XNe_8GANfE/s72-c/Java+Program+to+Implement+Simple+PageRank+Algorithm1.png" height="72" width="72"/><thr:total>16</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8083898279613891327.post-5087812397567318768</id><published>2015-12-13T22:38:00.007+05:30</published><updated>2020-05-25T20:07:26.551+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Java Program to Implement Prim&#39;s Minimum Spanning Tree </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;!--adsense--&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;A Spanning tree of a connected graph G is a acyclic subgraph of graph G that includes all vertices of G. A &lt;a href=&quot;https://en.wikipedia.org/wiki/Minimum_spanning_tree&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;minimum spanning tree&lt;/a&gt; of connected graph G is a graph that consists of minimum weights or edge costs to reach each of the vertices . Start with any one vertex and grow the tree one vertex at a time to produce minimum spanning tree with least total weight or edge cost.We are using &lt;a href=&quot;https://en.wikipedia.org/wiki/Prim%27s_algorithm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Prim&#39;s algorithm&lt;/a&gt; to find the minimum spanning tree .&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9q803QGsEkWlnRbUC8Z5J_Siv_0cpJLlpq9RrbpDATdxKLC_-PT2mxBXlkxG9AwipyXQFZTfdXirXdUJs81lCf4tCOnSSq0BOvgnbLbb44txNb7xei313tHSiROex672mar9qSAhP6WE/s1600/Java+Program+to+Implement+Prim%2527s+Minimum+Spanning+Tree+Algorithm.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Java Program to Implement Prim&#39;s Minimum Spanning Tree&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9q803QGsEkWlnRbUC8Z5J_Siv_0cpJLlpq9RrbpDATdxKLC_-PT2mxBXlkxG9AwipyXQFZTfdXirXdUJs81lCf4tCOnSSq0BOvgnbLbb44txNb7xei313tHSiROex672mar9qSAhP6WE/s1600/Java+Program+to+Implement+Prim%2527s+Minimum+Spanning+Tree+Algorithm.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;!--adsenseLink--&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #414a51; font-family: inherit; font-size: 16.8px; line-height: 26.88px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;h4 style=&quot;background-color: white; border: 0px; font-stretch: inherit; font-weight: 400; line-height: 1.4em; margin: 0px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: white; color: #414a51; font-family: inherit; font-size: 16.8px; line-height: 26.88px;&quot;&gt;&lt;b&gt;Also Read : &amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;a href=&quot;http://codispatch.blogspot.com/2015/12/java-program-implement-dijkstras-single-source-shortest-path-algorithm.html&quot; style=&quot;border: 0px; color: #02aace; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Java Program to Implement Dijkstra&#39;s Shortest Path Algorithm&lt;/a&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;span style=&quot;background-color: white; color: #414a51; font-family: inherit; font-size: 16.8px; line-height: 26.88px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #414a51; font-family: inherit; font-size: 16.8px; line-height: 26.88px;&quot;&gt;Take an Example for the Image below , We have four vertices a , b , c , d with their Cost weights are given in their edges.Source vertex is - Vertex &#39;a&#39; which is marked.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgddoyCateEL1rycGyzbXUAojhPPjHaIhMSE26g31n8CKSoPYSBXZ0KH3wCFlfFVuFzJwJjUmP-9zh8U0w7m8Dsh2-qWbkeMyP5bXPNOX_UhtXKAYX4jHd3ISIHsvjS6ET0qYOX9f7VDyU/s1600/dijkstras+Algorithm.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span style=&quot;color: black; font-family: inherit;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgddoyCateEL1rycGyzbXUAojhPPjHaIhMSE26g31n8CKSoPYSBXZ0KH3wCFlfFVuFzJwJjUmP-9zh8U0w7m8Dsh2-qWbkeMyP5bXPNOX_UhtXKAYX4jHd3ISIHsvjS6ET0qYOX9f7VDyU/s1600/dijkstras+Algorithm.png&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white; color: #414a51; font-family: inherit; font-size: 16.8px; line-height: 26.88px;&quot;&gt;First we write the Cost matrix as :&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;br style=&quot;background-color: white; color: #414a51; font-family: proxima-nova, &amp;quot;Proxima Nova&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16.8px; line-height: 26.88px;&quot; /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #414a51; font-family: inherit; font-size: 16.8px; line-height: 26.88px;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp;2 &amp;nbsp;3 &amp;nbsp;4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #414a51; font-family: inherit; font-size: 16.8px; line-height: 26.88px;&quot;&gt;&amp;nbsp;1 &amp;nbsp; i &amp;nbsp; 3 &amp;nbsp;i &amp;nbsp; 7&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #414a51; font-family: inherit; font-size: 16.8px; line-height: 26.88px;&quot;&gt;&amp;nbsp;2 &amp;nbsp; 3 &amp;nbsp;i &amp;nbsp; 4 &amp;nbsp; 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #414a51; font-family: inherit; font-size: 16.8px; line-height: 26.88px;&quot;&gt;&amp;nbsp;3 &amp;nbsp; i &amp;nbsp; 4 &amp;nbsp; i &amp;nbsp; 5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #414a51; font-family: inherit; font-size: 16.8px; line-height: 26.88px;&quot;&gt;&amp;nbsp;4 &amp;nbsp;7 &amp;nbsp; 2 &amp;nbsp; 5 &amp;nbsp;i&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: white; color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: white; color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;The Minimum Spanning Tree for the above example is :&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #414a51; font-family: inherit; font-size: 16.8px; line-height: 26.88px;&quot;&gt;a--&amp;gt;b : cost : 3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #414a51; font-family: inherit; font-size: 16.8px; line-height: 26.88px;&quot;&gt;b--&amp;gt;d : &amp;nbsp;cost : 2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: #414a51; font-family: inherit; font-size: 16.8px; line-height: 26.88px;&quot;&gt;b--&amp;gt;c : &amp;nbsp;cost : 4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: white; color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;background-color: white; font-size: 16.8px; line-height: 26.88px;&quot;&gt;Among all edges of vertex a ,we need to find the least or minimum cost edge &amp;amp; mark that vertex then we go to the next vertex .Similarly find the minimum edge for the next vertex so on until we cover (travel) all vertices with minimum cost to form Minimum Spanning Tree. Greedy part of this Algorithm is to find the minimum cost edge and growing the tree dynamically.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;b&gt;&lt;span style=&quot;background-color: white; font-size: 16.8px; line-height: 26.88px;&quot;&gt;Java Code to&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;Implement Prim&#39;s Minimum Spanning Tree :&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;pre&gt;
&lt;code class=&quot;java-html&quot;&gt;
import java.util.*;
public class Prims
{
    public  int isVisited[] = new int[15];
    public  int cost[][] = new int[10][10];
    public int minimum_cost;
     
    public void calc(int n)
    {   
        int flag[] = new int[n+1];
        int i,j,min=999,num_edges=1,a=1,b=1,minpos_i=1,minpos_j=1;
         
        while(num_edges &amp;lt; n)
        {    
            
            for(i=1,min=999;i&amp;lt;=n;i++)
             for(j=1;j&amp;lt;=n;j++)
              if(this.cost[i][j]&amp;lt;min)
                if(this.isVisited[i]!=0)
                 {
                      min=this.cost[i][j];
                      a=minpos_i=i;
                      b=minpos_j=j;
                 }
 				if(this.isVisited[minpos_i]==0 || this.isVisited[minpos_j]==0)
             	{
  					  System.out.println(&quot;Edge Number \t&quot;+num_edges+&quot;\t from Vertex \t&quot;+a+&quot;\t  to Vertex \t&quot;+b+&quot;-mincost:&quot;+min+&quot; \n&quot;);
                      this.minimum_cost=this.minimum_cost+min;
        			  num_edges=num_edges+1; 
                      this.isVisited[b]=1;
                }
                   this.cost[a][b]=this.cost[b][a]=999;   
        
        
        }   
         
    }
    
    public static void main(String args[])
    {
        int nodes,i,j;
        Scanner in = new Scanner(System.in);
        System.out.println(&quot;Enter the Number of Nodes \n&quot;);
        nodes = in.nextInt();
        Prims p = new Prims();
        System.out.println(&quot;Enter the Cost Matrix Weights : \n&quot;);
        for(i=1;i&amp;lt;=nodes;i++)
          for(j=1;j&amp;lt;=nodes;j++)
          {
            p.cost[i][j]=in.nextInt();
            if(p.cost[i][j]==0)
              p.cost[i][j]=999;
          }
       
        p.isVisited[1]=1; // Initialization 
        p.calc(nodes);
  
         
    }   
}
&lt;/code&gt;
&lt;/pre&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: red;&quot;&gt;Please Click and Drag from the beginning to End of the above Source code for Selection and Copying.&lt;/span&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;To Compile and Run :&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;javac Prims.java&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;java Prims&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;Enter the Number of Nodes :&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;4&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;Enter the Cost Matrix Weights :&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;0 &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;3 &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;999 &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;7&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;3 &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;0 &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;4 &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;999&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;4 &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;0 &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;5&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;7 &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;2 &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;5 &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;0&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;Edge Number &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;from Vertex &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; to Vertex &amp;nbsp; &amp;nbsp; 2 -mincost:3&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;Edge Number &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;from Vertex &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; to Vertex &amp;nbsp; &amp;nbsp; 4 -mincost:2&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;Edge Number &amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;from Vertex &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; to Vertex &amp;nbsp; &amp;nbsp; 3 -mincost:4&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;Prim&#39;s Minimum Spanning Tree containing Edges are numbered with its two vertices and minimum costs are shown in the Output above.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;Please Note : Once we Visit a node or an edge ,we make the cost 999 so that it should not visit that same node or an edge again . And also&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #414a51; font-size: 16.8px; line-height: 26.88px;&quot;&gt;this.isVisited[] ,this.minimum_cost and this.cost[][] basically refers to current object p&#39;s isVisited Array ,Minimum_Cost and Cost matrix .Thanks and Enjoy Coding.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #414a51;&quot;&gt;&lt;span style=&quot;font-size: 16.8px; line-height: 26.88px;&quot;&gt;If you have any Comments please let me know by Commenting below .&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h4 style=&quot;background-color: white; border: 0px; font-stretch: inherit; font-weight: 400; line-height: 1.4em; margin: 0px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: white; color: #414a51; font-family: inherit; font-size: 16.8px; line-height: 26.88px;&quot;&gt;&lt;b&gt;Also Read : &amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;a href=&quot;http://codispatch.blogspot.com/2015/12/java-program-implement-google-page-rank-algorithm.html&quot; style=&quot;border: 0px; color: #02aace; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Java Program to Implement Simple PageRank Algorithm&lt;/a&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;br /&gt;&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://codispatch.blogspot.com/feeds/5087812397567318768/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codispatch.blogspot.com/2015/12/java-program-implement-prims-minimum-spanning-tree-algorithm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/5087812397567318768'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/5087812397567318768'/><link rel='alternate' type='text/html' href='http://codispatch.blogspot.com/2015/12/java-program-implement-prims-minimum-spanning-tree-algorithm.html' title='Java Program to Implement Prim&#39;s Minimum Spanning Tree '/><author><name>Shravan C</name><uri>http://www.blogger.com/profile/07299338851374232212</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCkZjKG4qB0Hm70obtBjJFRtEdxW5Ui5iLXXHLbn9yi4TA14dHwN1KSlHF_GHXYtdiBCbFEOxWk4XGHqETjHVLLmQILELFkKXZPa18lkQzbrN3vvvqYL7HsgyJcSmb/s113/download.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9q803QGsEkWlnRbUC8Z5J_Siv_0cpJLlpq9RrbpDATdxKLC_-PT2mxBXlkxG9AwipyXQFZTfdXirXdUJs81lCf4tCOnSSq0BOvgnbLbb44txNb7xei313tHSiROex672mar9qSAhP6WE/s72-c/Java+Program+to+Implement+Prim%2527s+Minimum+Spanning+Tree+Algorithm.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8083898279613891327.post-5402276396473776038</id><published>2015-12-10T13:51:00.005+05:30</published><updated>2020-05-25T20:09:32.497+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Java Program to Implement Dijkstra&#39;s Shortest Path Algorithm</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;!--adsense--&gt;
Simple Java Program code to find the shortest path from single source using &lt;a href=&quot;http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Dijkstra&#39;s Single Source Shortest Path Algorithm&lt;/a&gt; .It is similar to Prim&#39;s algorithm but we are calculating the shortest path from just a single source to all other remaining vertices using Matrix.In this Java Program first we input the number of nodes and cost matrix weights for the graph ,then we input the source vertex . After that we get the distance matrix using Calc() method . Finally we print the distance matrix which has shortest distance from source vertex.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip7WFubG3bhWBZMQLUzqYe2NAAuxip54c4Gj1rD1z2wj5ymIgm_4eRTjGYMictKvD_MJpwJj6aSJvljZqFBMiYOqAgFny0P2uMAqVvsRdwpov3u5QgDroBnTfj_WGH62Bns95A4esHV-Y/s1600/Java+Program+to+Implement+Dijkstra%2527s+Shortest+Path+Algorithm.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Java Program to Implement Dijkstra&#39;s Shortest Path Algorithm&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip7WFubG3bhWBZMQLUzqYe2NAAuxip54c4Gj1rD1z2wj5ymIgm_4eRTjGYMictKvD_MJpwJj6aSJvljZqFBMiYOqAgFny0P2uMAqVvsRdwpov3u5QgDroBnTfj_WGH62Bns95A4esHV-Y/s1600/Java+Program+to+Implement+Dijkstra%2527s+Shortest+Path+Algorithm.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;!--adsenselink--&gt;
&lt;br /&gt;
Also Read :&lt;a href=&quot;http://codispatch.blogspot.com/2015/10/learn-to-create-patch-in-google-summer-code.html&quot; target=&quot;_blank&quot;&gt;&amp;nbsp;How to Create Patch in Google Summer of Coding&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Take an Example for the Image below , We have four vertices a , b , c , d with their Cost weights are given in their edges.Source vertex is : Vertex &#39;a&#39; which is marked.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgddoyCateEL1rycGyzbXUAojhPPjHaIhMSE26g31n8CKSoPYSBXZ0KH3wCFlfFVuFzJwJjUmP-9zh8U0w7m8Dsh2-qWbkeMyP5bXPNOX_UhtXKAYX4jHd3ISIHsvjS6ET0qYOX9f7VDyU/s1600/dijkstras+Algorithm.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Java Program to Implement Dijkstra&#39;s Shortest Path Algorithm&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgddoyCateEL1rycGyzbXUAojhPPjHaIhMSE26g31n8CKSoPYSBXZ0KH3wCFlfFVuFzJwJjUmP-9zh8U0w7m8Dsh2-qWbkeMyP5bXPNOX_UhtXKAYX4jHd3ISIHsvjS6ET0qYOX9f7VDyU/s1600/dijkstras+Algorithm.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
First we write the Cost matrix as :&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp;2 &amp;nbsp;3 &amp;nbsp;4&lt;br /&gt;
&amp;nbsp;1 &amp;nbsp; i &amp;nbsp; 3 &amp;nbsp;i &amp;nbsp; 7&lt;br /&gt;
&amp;nbsp;2 &amp;nbsp; 3 &amp;nbsp;i &amp;nbsp; 4 &amp;nbsp; 2&lt;br /&gt;
&amp;nbsp;3 &amp;nbsp; i &amp;nbsp; 4 &amp;nbsp; i &amp;nbsp; 5&lt;br /&gt;
&amp;nbsp;4 &amp;nbsp;7 &amp;nbsp; 2 &amp;nbsp; 5 &amp;nbsp;i&lt;br /&gt;
&lt;br /&gt;
Index position starts from 1 and ends at 4 . ( 1 to 4) and i stands for infinity or 999.We know that start or source vertex is &#39;a&#39; or 1.So the distance array from &#39;a&#39; to all other remaining vertices will be i , 3 , i , 7 .&lt;br /&gt;
&lt;br /&gt;
First we find the smallest element and its position in the distance array i , 3 , i , 7 which will be 3 and using the position of smallest element 3 we find the other shortest possible&amp;nbsp;available&amp;nbsp;paths . So the distance matrix will updated to i , 3 , 7 , 7 . We repeat this same process to get remaining shortest paths available .&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Java Program Code :&lt;/h4&gt;
&lt;br /&gt;
&lt;pre&gt;
&lt;code class=&quot;java-html&quot;&gt;
import java.util.*;
public class Dijkstra
{
 public  int distance[] = new int[10];
 public  int cost[][] = new int[10][10];
 
 public void calc(int n,int s)
 {
  int flag[] = new int[n+1];
  int i,minpos=1,k,c,minimum;
  
  for(i=1;i&amp;lt;=n;i++)
  {  
      flag[i]=0; 
      this.distance[i]=this.cost[s][i]; 
  }
  c=2;
  while(c&amp;lt;=n)
  {
   minimum=99;
   for(k=1;k&amp;lt;=n;k++)
   { 
          if(this.distance[k]&amp;lt;minimum &amp;amp;&amp;amp; flag[k]!=1)
       {
        minimum=this.distance[i];
        minpos=k;
       }
      } 
            flag[minpos]=1;
      c++;
      for(k=1;k&amp;lt;=n;k++){
       if(this.distance[minpos]+this.cost[minpos][k] &amp;lt;  this.distance[k] &amp;amp;&amp;amp; flag[k]!=1 )
       this.distance[k]=this.distance[minpos]+this.cost[minpos][k];
   }   
  } 
  
 }
 public static void main(String args[])
 {
  int nodes,source,i,j;
  Scanner in = new Scanner(System.in);
  System.out.println(&quot;Enter the Number of Nodes \n&quot;);
  nodes = in.nextInt();
  Dijkstra d = new Dijkstra();
  System.out.println(&quot;Enter the Cost Matrix Weights: \n&quot;);
        for(i=1;i&amp;lt;=nodes;i++)
          for(j=1;j&amp;lt;=nodes;j++)
          {
            d.cost[i][j]=in.nextInt();
            if(d.cost[i][j]==0)
              d.cost[i][j]=999;
          }
  System.out.println(&quot;Enter the Source Vertex :\n&quot;);
  source=in.nextInt();
  
  d.calc(nodes,source);
  System.out.println(&quot;The Shortest Path from Source \t&quot;+source+&quot;\t to all other vertices are : \n&quot;);
        for(i=1;i&amp;lt;=nodes;i++)
          if(i!=source)
  System.out.println(&quot;source :&quot;+source+&quot;\t destination :&quot;+i+&quot;\t MinCost is :&quot;+d.distance[i]+&quot;\t&quot;);
        
  
 } 
}
&lt;/code&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;Please Click and Drag from the beginning to End of the above Source code for Selection and Copying.&lt;/span&gt;&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;To Compile and Run Java Program for the above Example :&lt;/h4&gt;
javac Dijkstra.java&lt;br /&gt;
java Dijkstra&lt;br /&gt;
&lt;br /&gt;
Enter the Number of Nodes :4&lt;br /&gt;
Enter the Cost Matrix Weights:&lt;br /&gt;
0 &amp;nbsp; &amp;nbsp; &amp;nbsp;3 &amp;nbsp; 999 &amp;nbsp; 7&lt;br /&gt;
3 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp;4 &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;br /&gt;
999 &amp;nbsp;4 &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;5&lt;br /&gt;
7 &amp;nbsp; &amp;nbsp; &amp;nbsp;2 &amp;nbsp; &amp;nbsp;5 &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;br /&gt;
Enter the Source Vertex :&lt;br /&gt;
1&lt;br /&gt;
The Shortest Path from Source &amp;nbsp;Vertex &amp;nbsp;1 &amp;nbsp;to all other vertices are :&lt;br /&gt;
&lt;br /&gt;
source :1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;destination :2 &amp;nbsp; MinCost is :3&lt;br /&gt;
source :1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;destination :3 &amp;nbsp; MinCost is :7&lt;br /&gt;
source :1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;destination :4 &amp;nbsp; MinCost is :5&lt;br /&gt;
&lt;br /&gt;
Please Note that this.distance[] and this.cost[][] basically refers to current object d&#39;s distance and Cost matrix .Thanks and Enjoy Coding.&lt;br /&gt;
&lt;br /&gt;
If you have any Comments please let me know .&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h4 style=&quot;background-color: white; border: 0px; font-stretch: inherit; font-weight: 400; line-height: 1.4em; margin: 0px; padding: 0px; text-align: left; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: white; color: #414a51; font-family: inherit; font-size: 16.8px; line-height: 26.88px;&quot;&gt;&lt;b&gt;Also Read : &amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;a href=&quot;http://codispatch.blogspot.com/2015/12/java-program-implement-prims-minimum-spanning-tree-algorithm.html&quot; style=&quot;border: 0px; color: #02aace; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; outline: 0px; padding: 0px; text-decoration: none; vertical-align: baseline;&quot; target=&quot;_blank&quot;&gt;Java Program to Implement Prim&#39;s Minimum Spanning Tree&lt;/a&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codispatch.blogspot.com/feeds/5402276396473776038/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codispatch.blogspot.com/2015/12/java-program-implement-dijkstras-single-source-shortest-path-algorithm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/5402276396473776038'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/5402276396473776038'/><link rel='alternate' type='text/html' href='http://codispatch.blogspot.com/2015/12/java-program-implement-dijkstras-single-source-shortest-path-algorithm.html' title='Java Program to Implement Dijkstra&#39;s Shortest Path Algorithm'/><author><name>Shravan C</name><uri>http://www.blogger.com/profile/07299338851374232212</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCkZjKG4qB0Hm70obtBjJFRtEdxW5Ui5iLXXHLbn9yi4TA14dHwN1KSlHF_GHXYtdiBCbFEOxWk4XGHqETjHVLLmQILELFkKXZPa18lkQzbrN3vvvqYL7HsgyJcSmb/s113/download.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEip7WFubG3bhWBZMQLUzqYe2NAAuxip54c4Gj1rD1z2wj5ymIgm_4eRTjGYMictKvD_MJpwJj6aSJvljZqFBMiYOqAgFny0P2uMAqVvsRdwpov3u5QgDroBnTfj_WGH62Bns95A4esHV-Y/s72-c/Java+Program+to+Implement+Dijkstra%2527s+Shortest+Path+Algorithm.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8083898279613891327.post-8945167637947570234</id><published>2015-12-08T17:52:00.001+05:30</published><updated>2020-05-25T20:11:13.054+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithms"/><category scheme="http://www.blogger.com/atom/ns#" term="Java"/><title type='text'>Java Program to Search Pattern using Horspool Algorithm</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;!--adsense--&gt;
Horspool Algorithm is used to search the pattern in the given string using a shift table. Its another variation of the Boyer-Moore Algorithm where it uses two shift tables - bad shift table and good suffix table but in Horspool Algorithm we are using just one shift table to search the pattern in the given string.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMdHbTT9bDrBPBhKXcSvDaP6-rxeRqxyfSgaM3yrOMhk8-VljaYX-8kMF7kH7e_VP75mXliNFBX47oED757mYW7Km2T5KAcZUsPnrHPu6jKB0yNnRYp7E-6zU7Pqsy8thKSE5Lsj1nG8w/s1600/Java+Program+to+Search+Pattern+using+Horspool+Algorithm.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Java Program to Search Pattern using Horspool Algorithm&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMdHbTT9bDrBPBhKXcSvDaP6-rxeRqxyfSgaM3yrOMhk8-VljaYX-8kMF7kH7e_VP75mXliNFBX47oED757mYW7Km2T5KAcZUsPnrHPu6jKB0yNnRYp7E-6zU7Pqsy8thKSE5Lsj1nG8w/s1600/Java+Program+to+Search+Pattern+using+Horspool+Algorithm.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;!--adsenselink--&gt;

&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
What is Shift Table in Horspool Algorithm ?&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
A shift table is the table that contains two things : -&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Either length of the Pattern to be searched&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Or distance of first occurrence of each character from the right most side of the pattern.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
To know more about the &lt;a href=&quot;https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore%E2%80%93Horspool_algorithm&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Horspool Algorithm&lt;/a&gt;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
&lt;code class=&quot;java-html&quot;&gt;
import java.util.*;
public class Horspool  {
  
   public static int SIZE=500;    
   public static int table[]=new int[SIZE];
  
public void shifttable(String pattern) {
 
 int i,j,m;
 char p[] = pattern.toCharArray();
 m=pattern.length();
 
 for (i=0;i&amp;lt;SIZE;i++)
    table[i]=m;
 for (j=0;j&amp;lt;m;j++)
    table[p[j]]=m-1-j;
}
public int horspool(String source,String pattern)
  {
      int i,k,pos,m;
      char s[] = source.toCharArray();
      char p[] = pattern.toCharArray();
      m=pattern.length();
     
      for(i=m-1;i&amp;lt;source.length();)
        {
           k=0;
            while((k&amp;lt;m) &amp;amp;&amp;amp; (p[m-1-k] == s[i-k]))
              k++;
           if(k==m) 
     {   pos=i-m+2;
               return pos;
     } 
           else
               i+=table[s[i]];
        }
        return -1;
  } 
     public static void main(String []args){
        int pos; 
  String source=args[0];
        String pattern = args[1];
  
        Horspool  h = new Horspool ();
        
        h.shifttable(pattern);
        pos = h.horspool(source,pattern);
  
        if(pos == -1)
            System.out.println(&quot;PATTERN NOT FOUND&quot;);
        else
            System.out.println(&quot;PATTERN FOUND FROM POSITION: \t&quot;+pos+&quot;\n&quot;);
     }
}
&lt;/code&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;Please Click and Drag from the beginning to End of the above Source code for Selection and Copying.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;
&lt;b&gt;To compile and run :&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
javac Horspool.java&lt;br /&gt;
java Horspool Testingstring ting&lt;br /&gt;
&lt;br /&gt;
Output : &amp;nbsp; PATTERN FOUND FROM POSITION: &amp;nbsp; &amp;nbsp;&lt;b&gt;4&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Please Note :&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Testingstring&lt;/b&gt; is the source string and &lt;b&gt;ting&lt;/b&gt; is the Pattern to be Searched both are given while running the Java Program and are accepted using args[0]=Source String and args[1]=Pattern to be Search in the program. You can change this if you want in the program .Thank you.&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codispatch.blogspot.com/feeds/8945167637947570234/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codispatch.blogspot.com/2015/12/java-program-to-search-pattern-horspool-algorithm.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/8945167637947570234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/8945167637947570234'/><link rel='alternate' type='text/html' href='http://codispatch.blogspot.com/2015/12/java-program-to-search-pattern-horspool-algorithm.html' title='Java Program to Search Pattern using Horspool Algorithm'/><author><name>Shravan C</name><uri>http://www.blogger.com/profile/07299338851374232212</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCkZjKG4qB0Hm70obtBjJFRtEdxW5Ui5iLXXHLbn9yi4TA14dHwN1KSlHF_GHXYtdiBCbFEOxWk4XGHqETjHVLLmQILELFkKXZPa18lkQzbrN3vvvqYL7HsgyJcSmb/s113/download.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMdHbTT9bDrBPBhKXcSvDaP6-rxeRqxyfSgaM3yrOMhk8-VljaYX-8kMF7kH7e_VP75mXliNFBX47oED757mYW7Km2T5KAcZUsPnrHPu6jKB0yNnRYp7E-6zU7Pqsy8thKSE5Lsj1nG8w/s72-c/Java+Program+to+Search+Pattern+using+Horspool+Algorithm.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8083898279613891327.post-9044354564511355391</id><published>2015-11-08T20:08:00.002+05:30</published><updated>2020-05-25T20:13:29.804+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>How to Extract the IP Address of the Visitor (Client) | PHP </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;!--adsense--&gt;
&lt;span style=&quot;background-color: white; font-family: inherit;&quot;&gt;To extract IP Address of any real Website visitor or client using PHP , We should have some basic idea about predefined variables that are used in PHP. The predefined variables in PHP are Superglobal&amp;nbsp;&lt;span style=&quot;line-height: 24px;&quot;&gt;, which means they are available in all scopes throughout a script. There is no need to do&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;command&quot; style=&quot;line-height: 24px; text-rendering: optimizelegibility;&quot;&gt;global $variable;&lt;/span&gt;&lt;span style=&quot;line-height: 24px;&quot;&gt;&amp;nbsp;to access them within functions or methods.&lt;/span&gt;&amp;nbsp;Under this predefined variables we need look at $_SERVER[&#39;___&#39;] variable to get IP Address .&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJc-9vByq0HJZF_ZiS_iiFZ-xOtQwsyb72DcezA4IHie3TTibroPYfTkP_bDL2h959N6UpIGF3lWlbzRbQsQBqRGBiV1ZteYx7RueSsFhekXr4R5g5hDFyzIlJpCzY5X-bxWuxSu8fEWw/s1600/IP_ADDRESS_PHP.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;How to Extract the IP Address of the Visitor (Client) | PHP&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJc-9vByq0HJZF_ZiS_iiFZ-xOtQwsyb72DcezA4IHie3TTibroPYfTkP_bDL2h959N6UpIGF3lWlbzRbQsQBqRGBiV1ZteYx7RueSsFhekXr4R5g5hDFyzIlJpCzY5X-bxWuxSu8fEWw/s1600/IP_ADDRESS_PHP.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: white; font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;!--adsenselink--&gt;
$_SERVER is an array containing information such as headers, paths and script locations.The entries in this array are created by the web server .&lt;br /&gt;
&lt;br /&gt;
You can get more details of $_SERVER :&amp;nbsp;&lt;a href=&quot;http://php.net/manual/en/reserved.variables.server.php&quot; target=&quot;_blank&quot;&gt;http://php.net/manual/en/reserved.variables.server.php&lt;/a&gt;&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
How to extract IP Address of the Visitor ?&lt;/h3&gt;
&lt;div&gt;
IP address of the Client or user who viewed your Website can be got by using $_SERVER[&#39;REMOTE_ADDR&#39;] . This will Print the IP Address of the Visitor (viewer) who requested the webpage to the Server . So when the request is made to the Server ,It stores the IP Address in $_Server Global variable which can be accessed using $_SERVER[&#39;REMOTE_ADDR&#39;] variable .&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre&gt;
&lt;code class=&quot;php-html&quot;&gt;
&amp;lt;?php 
 $ipaddress = &#39;&#39;;

if($_SERVER[&#39;REMOTE_ADDR&#39;])
      $ipaddress = $_SERVER[&#39;REMOTE_ADDR&#39;];

echo  &quot;\n Your IP Address is :\t&quot;.$ipaddress;

?&amp;gt; 
&lt;/code&gt;
&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: inherit;&quot;&gt;You Can view the Demo here :&amp;nbsp;&lt;a href=&quot;http://codispatch.co.nf/demos/IPADDRESS/index.php&quot; target=&quot;_blank&quot;&gt;Codispatch Demo&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: inherit;&quot;&gt;How to extract Real IP address if the Visitor is using Proxy Server ?&lt;/span&gt;&lt;/h3&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; font-family: inherit;&quot;&gt;Some times visitor can spoof or hide the actual IP address that is assigned to that user and use Proxy Server address instead. This is commonly done using&amp;nbsp;&lt;a href=&quot;http://proxylist.hidemyass.com/&quot; target=&quot;_blank&quot;&gt;Hidemyass Proxy List&lt;/a&gt;&amp;nbsp; . Now we can&#39;t get the actual IP address of the visitor using PHP but we do can detect if it is Proxy Server or not, this is done by&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;pre&gt;
&lt;code class=&quot;php-html&quot;&gt;
&amp;lt;?php 
$realipaddress = &#39;&#39;;

if ( $_SERVER[&#39;HTTP_X_FORWARDED_FOR&#39;] || $_SERVER[&#39;HTTP_X_FORWARDED&#39;] || $_SERVER[&#39;HTTP_FORWARDED_FOR&#39;] || $_SERVER[&#39;HTTP_CLIENT_IP&#39;] || $_SERVER[&#39;HTTP_VIA&#39;] || in_array($_SERVER[&#39;REMOTE_PORT&#39;], array(8080,80,6588,8000,3128,553,554)) || @fsockopen($_SERVER[&#39;REMOTE_ADDR&#39;], 80, $errno, $errstr, 30))
{
     $realipaddress = &quot;Proxy detected \t&quot;.$_SERVER[&#39;REMOTE_ADDR&#39;];
  echo $realipaddress;
}
?&amp;gt; 
&lt;/code&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
You can view the Demo here :&amp;nbsp;&lt;a href=&quot;http://codispatch.co.nf/demos/IPADDRESS/index.php&quot; target=&quot;_blank&quot;&gt;Codispatch Demo&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
(Note that you must use or spoof some Proxy server address in-order to understand the above demo )&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQl0H9UK_7-_fKU05ihRTVhEEvHU-4hhGOtjjZeoTrczHpcQtOE8yTUCXE2gip2jQ0LZ4tAU0LgjnYtCmz1y38TTGmz_8ifLPD6P7TjB12AkydKNkA5Z_KUptp1ZS5SrtugsMqqzt-Zr0/s1600/IPADDRESS.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;How to Extract the IP Address of the Visitor (Client) | PHP&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQl0H9UK_7-_fKU05ihRTVhEEvHU-4hhGOtjjZeoTrczHpcQtOE8yTUCXE2gip2jQ0LZ4tAU0LgjnYtCmz1y38TTGmz_8ifLPD6P7TjB12AkydKNkA5Z_KUptp1ZS5SrtugsMqqzt-Zr0/s1600/IPADDRESS.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now you know how to extract the IP address of the Visitor even if the user is using Proxy Server .If you have any questions or suggestions please comment it below .&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Also Read : &amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://codispatch.blogspot.com/2015/07/login-password-protected-page-using.html&quot; style=&quot;color: #660099; cursor: pointer; font-family: arial, sans-serif; font-size: 18px; font-weight: normal; white-space: nowrap;&quot; target=&quot;_blank&quot;&gt;Login Password Protected Page using Sessions | PHP&lt;/a&gt;&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://codispatch.blogspot.com/feeds/9044354564511355391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codispatch.blogspot.com/2015/11/php-extract-ip-address-of-visitor-client.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/9044354564511355391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/9044354564511355391'/><link rel='alternate' type='text/html' href='http://codispatch.blogspot.com/2015/11/php-extract-ip-address-of-visitor-client.html' title='How to Extract the IP Address of the Visitor (Client) | PHP '/><author><name>Shravan C</name><uri>http://www.blogger.com/profile/07299338851374232212</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCkZjKG4qB0Hm70obtBjJFRtEdxW5Ui5iLXXHLbn9yi4TA14dHwN1KSlHF_GHXYtdiBCbFEOxWk4XGHqETjHVLLmQILELFkKXZPa18lkQzbrN3vvvqYL7HsgyJcSmb/s113/download.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJc-9vByq0HJZF_ZiS_iiFZ-xOtQwsyb72DcezA4IHie3TTibroPYfTkP_bDL2h959N6UpIGF3lWlbzRbQsQBqRGBiV1ZteYx7RueSsFhekXr4R5g5hDFyzIlJpCzY5X-bxWuxSu8fEWw/s72-c/IP_ADDRESS_PHP.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8083898279613891327.post-7788045311211282117</id><published>2015-10-06T20:05:00.000+05:30</published><updated>2019-09-17T07:06:22.319+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Learn-Fast"/><title type='text'>How to Create Patch in Google Summer of Coding | Learn-Fast</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;!-- adsense --&gt;
In Order to submit Patches for Google Summer of Code , you must be comfortable in reading source code and finding Bugs/issues in them.Well every Organisation will have a Bug Tracker System that has a set of Solved and Unsolved Bugs/Issues which are usually labelled with their difficultly Level ,like first-Timer, Easy, Medium or Hard .In this Post we &#39;ll be covering How to Create a Patch after you detected and worked on some Bugs / Issues .&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnwPlW2oQMzZjRlfO_Hzeg80nUrUtLrWr0S5iCv-olOE3gEjwZ4NA3qySaEdfVzVMQVbC2GqGTuN6k3ZqMpflmUZjoP4vYZ_ZvYwFviXJctyYh7MVd25kLwMGOa3vECtXhq3KLxc7-lbU/s1600/GSOC_PATCH.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; alt=&quot;Learn to Create Patch in Google Summer of Coding&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnwPlW2oQMzZjRlfO_Hzeg80nUrUtLrWr0S5iCv-olOE3gEjwZ4NA3qySaEdfVzVMQVbC2GqGTuN6k3ZqMpflmUZjoP4vYZ_ZvYwFviXJctyYh7MVd25kLwMGOa3vECtXhq3KLxc7-lbU/s1600/GSOC_PATCH.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;!-- adsenselink --&gt;
&lt;br /&gt;
A Patch is simply a file usually a text file that has some additional information that you have added after manipulating your original file .&lt;br /&gt;
&lt;br /&gt;
If you made some changes to your original Code and wanted to share them with the Core Developers of the community (Organisation) then it is very helpful to provide them a Patch file .&lt;br /&gt;
&lt;br /&gt;
Now we know what is a patch , lets create one . Patches can be created in many ways .Some of them which are often used in Google Summer of Coding Contests are listed below :&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;Create Patch using Diff&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Create Patch using WinMerge&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Create Patch using Git&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Create Patch using Diff &lt;/b&gt;:&lt;/h4&gt;
Diff is simple Linux command that requires two copies of code or a file .The first is the Original code or a file and later is the modified (With some changes you made) Code or a file .&lt;br /&gt;
&lt;br /&gt;
To illustrates this , we put the below code in the Foo.java File .&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;import java.util.*;
public class Foo {
   public void main(String[] args)
   { 
     System.out.println(&quot;Foo&quot;);  
   }
}&lt;/pre&gt;
Next , we modify the above code and save them in Foobar.java .&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;import java.util.*;
import java.util.*;
public class Foobar {
public void main(String[] args)
{ 
    System.out.println(&quot;Foobar Foo&quot;);  
}
}
&lt;/pre&gt;
&lt;br /&gt;
To trace what changes you have made , just type in the Linux terminal&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;diff -u Foo.java Foobar.java &amp;gt; PatchforFoo.patch
&lt;/pre&gt;
&amp;nbsp; &lt;br /&gt;
The above Code will create patch file called PatchforFoo which shows difference in contents&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;import java.util.*;
--- Foo.java 2015-10-06 09:40:14.525429605 +0530
+++ Foobar.java 2015-10-06 09:43:29.365427829 +0530
@@ -5,7 +5,7 @@
 public void main(String[] args)
 { 
-System.out.println(&quot;Foo&quot;);  
+System.out.println(&quot;Foobar Foo&quot;);  
 }
&lt;/pre&gt;
&lt;br /&gt;
You can also apply patch in Source Tree or directory .Type in the Linux Terminal&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;diff -Naur /usr/src/originalfolder &amp;nbsp;/usr/src/modifiedfolder &amp;gt; patchforgsoc.patch

&lt;/pre&gt;
&lt;br /&gt;
All those modified differences are placed in patchforgsoc patch file .&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Create Patch using WinMerge :&lt;/b&gt;&lt;/h4&gt;
WinMerge is a Simple Open Source GUI based Tool for Windows that is used to compare folder contents and merging. To start with ,first you need to download the &lt;a href=&quot;http://winmerge.org/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;WinMerge&lt;/a&gt; Software . To create the patch ,click FILE-&amp;gt;Open and Open two versions for comparisons .then click TOOLS-&amp;gt;Generate patch .&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Create Patch using Git :&lt;/b&gt;&lt;/h4&gt;
&lt;div&gt;
Many Organisations use Git Version Control has it is more secure and use distributed system for concurrent access . If you are new to Git version Control&amp;nbsp;&lt;a href=&quot;https://try.github.io/levels/1/challenges/1&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Try Git&lt;/a&gt;&amp;nbsp;.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
To create patch in Git ,just open the Git console and if you want to create a patch file for last commit ,type&lt;span style=&quot;background-color: #cccccc;&quot;&gt; git show &amp;gt; patchforgsoc.txt&lt;/span&gt; .&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&amp;nbsp;If you want to create patch for 2 commits you can type &lt;span style=&quot;background-color: #cccccc;&quot;&gt;git diff commit1 commit2 &amp;gt; patchforgsoc.txt&lt;/span&gt;&lt;br /&gt;
So modified differences are placed in patchforgsoc.txt text file .&lt;br /&gt;
&lt;br /&gt;
In general the git patch format looks like this &lt;span style=&quot;background-color: #cccccc;&quot;&gt;git format-patch [options]&lt;/span&gt; . Check the detailed explanation for git patch Options&amp;nbsp;&lt;a href=&quot;http://git-scm.com/docs/git-format-patch&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://codispatch.blogspot.com/feeds/7788045311211282117/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codispatch.blogspot.com/2015/10/learn-to-create-patch-in-google-summer-code.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/7788045311211282117'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/7788045311211282117'/><link rel='alternate' type='text/html' href='http://codispatch.blogspot.com/2015/10/learn-to-create-patch-in-google-summer-code.html' title='How to Create Patch in Google Summer of Coding | Learn-Fast'/><author><name>Shravan C</name><uri>http://www.blogger.com/profile/07299338851374232212</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCkZjKG4qB0Hm70obtBjJFRtEdxW5Ui5iLXXHLbn9yi4TA14dHwN1KSlHF_GHXYtdiBCbFEOxWk4XGHqETjHVLLmQILELFkKXZPa18lkQzbrN3vvvqYL7HsgyJcSmb/s113/download.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjnwPlW2oQMzZjRlfO_Hzeg80nUrUtLrWr0S5iCv-olOE3gEjwZ4NA3qySaEdfVzVMQVbC2GqGTuN6k3ZqMpflmUZjoP4vYZ_ZvYwFviXJctyYh7MVd25kLwMGOa3vECtXhq3KLxc7-lbU/s72-c/GSOC_PATCH.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8083898279613891327.post-3187783071587056947</id><published>2015-07-19T15:06:00.001+05:30</published><updated>2019-09-17T07:07:40.274+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>Login Password Protected Page using Sessions | PHP </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;!-- adsense --&gt;
This Tutorial will teach you to control and protect the access of any web page using PHP Sessions. We basically store some reference or item in the web browser and it is used every time when the user navigates from one web page to other web page , both pages of the same website. So for the first time the user has to go through login and later the user have to login only if browser content is cleared or the user&#39;s session expires.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirk__v9QD_pVu5OMVsQCD7EIavOz_Azw7qkj_GqSH78kHv0Zv7Z4CGAEp5eP1H-9fTvgIk5uBMWBJKTVYZauuUNuSCm9cO_n2JYJxeR0SHMwumyTSX4coLrms4yNohkY4NPrxw6LcVx4g/s1600/Login+Password+Protected+Page+using+Sessions-min.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Login Password Protected Page using PHP Sessions &quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirk__v9QD_pVu5OMVsQCD7EIavOz_Azw7qkj_GqSH78kHv0Zv7Z4CGAEp5eP1H-9fTvgIk5uBMWBJKTVYZauuUNuSCm9cO_n2JYJxeR0SHMwumyTSX4coLrms4yNohkY4NPrxw6LcVx4g/s1600/Login+Password+Protected+Page+using+Sessions-min.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;!-- adsenselink --&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Agenda :&amp;nbsp;&lt;/h4&gt;
&lt;div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;Set Session Global Variable in your PHP Login Page .&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Create checkSession() Function to Validate user is already logged in or not.&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;PHP Script that is added to every Web Page that you want to Protect from unauthorized Access&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Set Session Global Variable in your PHP Login Page .&lt;/h4&gt;
&lt;/div&gt;
&lt;div&gt;
Just go to your Login Page . Add session_start(); function before all of the other Codes .&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinLjmGDiDD9-r_nCanfwqIbSSC8hYGIXqSkdV7lneFgDcadtp33uk90z-CrlM8CYs-9EcfnXG6o6OvLRMdw2-z_Oq5bVW4RXqfSuokZNqwQQ2rvjAx5OwcZEp_CxAeO2HW2T24i_mn2kY/s1600/Login+Password+Protected+Page+using+PHP+Sessions+1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Login Password Protected Page using PHP Sessions &quot; border=&quot;0&quot; height=&quot;162&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinLjmGDiDD9-r_nCanfwqIbSSC8hYGIXqSkdV7lneFgDcadtp33uk90z-CrlM8CYs-9EcfnXG6o6OvLRMdw2-z_Oq5bVW4RXqfSuokZNqwQQ2rvjAx5OwcZEp_CxAeO2HW2T24i_mn2kY/s640/Login+Password+Protected+Page+using+PHP+Sessions+1.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;Next we store item like username or email etc in the Global Session variable .&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
If your using MySQL Database or any Similar Database to check the Login credentials. Write a query to get username or email or any other item that you want to store in your Session.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
For example : If I Want to Store Username in the Session Variable ,please see the below Code.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush:php&quot;&gt; $query_session = &quot;SELECT username FROM Table_Name WHERE (email=&#39;&quot;.$email.&quot;&#39; AND password=&#39;&quot;.$password.&quot;&#39;)&quot;;
 $result = mysql_query($query_session);
 $result_session = mysql_fetch_array($result);
 //Assign the result of this query to SESSION Global Variable named username
 $_SESSION[&#39;username&#39;]=$result_session[&#39;username&#39;];&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Session Global Variable $_SESSION[&#39;username&#39;] or $_SESSION[&#39;email&#39;] is used to Store with Database retrieved Data .&lt;br /&gt;
&lt;br /&gt;
Now save your Login Page as .php file .Any other format will not work or render properly . Don&#39;t Worry if it is in .html format or any other format ,the (PHP) Server will render html format or any other format as-well .&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Create checkSession() Function to Validate user is already logged-in or not&amp;nbsp;&lt;/h4&gt;
&lt;pre class=&quot;brush:php&quot;&gt;&amp;lt;?php
// This is a Generic Session Function to check Session username or Email or variable
function checkSession()
{
if(!isset($_SESSION)){ session_start(); }

         $username=$_SESSION[&#39;username&#39;];
         
         if(empty($username))
         {
            return true;
         }
         return false;
}
?&amp;gt;&lt;/pre&gt;
&lt;br /&gt;
Save the Above Code as Session.php . If &amp;nbsp;$_SESSION[&#39;username&#39;] or $_SESSION[&#39;email&#39;] or any other reference or item that you&#39;ve store in the step 1 is empty &amp;nbsp;then return true or else return false.&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
 &lt;!-- adsense --&gt;PHP Script that is added to every Web Page that you want to Protect from unauthorized Access&lt;/h4&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:php&quot;&gt;&amp;lt;?PHP
require_once(&quot;session.php&quot;);
if(checkSession())
{
    header(&quot;Location: http://your_Login-in_page.php&quot;);
    exit;
}
?&amp;gt;&lt;/pre&gt;
&lt;br /&gt;
Above Code must be added to first Line of any Web Page that you want to protect it from unauthorized access. The checkSession() will return true if $_SESSION[&#39;username&#39;]; is empty which means the user is not logged-in ,So send that user to Log-in Page . If checkSession() functions returns false then the user is logged-in which means $_SESSION[&#39;username&#39;]; Global Session Variable is not empty . Please See the Image below .&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4Hp1SlJTLu0DplvfK80cQhGcyH6wKThMRUnl-sN9Vrxde5tOXqO_riij82TpH4GSfci-0rGyW3KR_eqqUY4Qm17PP2FVdFlM-4SqdUW7eLgMhkLcmHhHt3I6uLdzHKfJq85xxeGKeTJ4/s1600/Login+Password+Protected+Page+using+Sessions+2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;Login Password Protected Page using PHP Sessions &quot; border=&quot;0&quot; height=&quot;286&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4Hp1SlJTLu0DplvfK80cQhGcyH6wKThMRUnl-sN9Vrxde5tOXqO_riij82TpH4GSfci-0rGyW3KR_eqqUY4Qm17PP2FVdFlM-4SqdUW7eLgMhkLcmHhHt3I6uLdzHKfJq85xxeGKeTJ4/s640/Login+Password+Protected+Page+using+Sessions+2.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;Please note :Save your file as .PHP format.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
All done .Now any Web Page which has checkSession() PHP script installed is protected from unauthorized access .&lt;br /&gt;
&lt;br /&gt;
Updated :&lt;br /&gt;
&lt;br /&gt;
Disclaimer: Storing username &amp;amp; password directly as plain-text is not good practice and may lead to security threats , so MD5 (encrypt) them then store it .&lt;br /&gt;
This is just a plain simple concept of using sessions with PHP .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;Also Read : &amp;nbsp;&lt;/span&gt;&lt;a data-href=&quot;http://codispatch.blogspot.com/2015/11/php-extract-ip-address-of-visitor-client.html&quot; href=&quot;http://codispatch.blogspot.com/2015/11/php-extract-ip-address-of-visitor-client.html&quot; style=&quot;color: #660099; cursor: pointer; font-family: arial, sans-serif; font-size: 18px; font-weight: normal; white-space: nowrap;&quot; target=&quot;_blank&quot;&gt;How to Extract the IP Address of the Visitor (Client)&lt;/a&gt;&lt;/h4&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://codispatch.blogspot.com/feeds/3187783071587056947/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://codispatch.blogspot.com/2015/07/login-password-protected-page-using.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/3187783071587056947'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8083898279613891327/posts/default/3187783071587056947'/><link rel='alternate' type='text/html' href='http://codispatch.blogspot.com/2015/07/login-password-protected-page-using.html' title='Login Password Protected Page using Sessions | PHP '/><author><name>Shravan C</name><uri>http://www.blogger.com/profile/07299338851374232212</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCkZjKG4qB0Hm70obtBjJFRtEdxW5Ui5iLXXHLbn9yi4TA14dHwN1KSlHF_GHXYtdiBCbFEOxWk4XGHqETjHVLLmQILELFkKXZPa18lkQzbrN3vvvqYL7HsgyJcSmb/s113/download.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirk__v9QD_pVu5OMVsQCD7EIavOz_Azw7qkj_GqSH78kHv0Zv7Z4CGAEp5eP1H-9fTvgIk5uBMWBJKTVYZauuUNuSCm9cO_n2JYJxeR0SHMwumyTSX4coLrms4yNohkY4NPrxw6LcVx4g/s72-c/Login+Password+Protected+Page+using+Sessions-min.png" height="72" width="72"/><thr:total>3</thr:total></entry></feed>