├── HYDmetromap.jpg ├── graph_representation.png ├── LICENCE ├── README.md └── dijkstras.cpp /HYDmetromap.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mak-3/Dijkstras-algorithm-HYDmetro/HEAD/HYDmetromap.jpg -------------------------------------------------------------------------------- /graph_representation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mak-3/Dijkstras-algorithm-HYDmetro/HEAD/graph_representation.png -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Mak-3 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dijkstras-algorithm-HYDmetro 2 | ***INTRODUCTION:*** 3 | This C++ code implements real time use case of Dijkstras algorithm to find the shortest path from source to every destination.There are 56 metro stations in Hyderabad. Considering each station an integer value starting from 0 is assigned,when the user enters the source station Dijkstras algorithm is applied and least no of stations from the source to every other station is calculated and displayed. 4 | 5 | ***COMPLEXITY:*** 6 | The time complexity of Dijkstras algorithm is O(V^2),where V is the number of vertices in the graph.The space complexity of Dijkstras algorithm is O(V) 7 | 8 | Please follow the link for the same project developed in java: https://github.com/ASMA-GIT/Hyderabad-Metro-DijkstraAlgo 9 | 10 | # STATION CODES 11 | Node number Station Name 12 | 13 | 0 LBnagar 14 | 1 Victoria_memorial 15 | 2 Chaitanyapuri 16 | 3 Dilshukhnagar 17 | 4 Moosrambagh 18 | 5 New Market 19 | 6 Malakpet 20 | 7 MG BusStation 21 | 8 Osmania_medical 22 | 9 GandhiBhavan 23 | 10 Assembly 24 | 11 Lakdikapool 25 | 12 Khairtabad 26 | 13 Irrummanzil 27 | 14 Panjagutta 28 | 15 Ameerpet 29 | 16 SRnagar 30 | 17 ESIhospital 31 | 18 Erragadda 32 | 20 Bharatnagar 33 | 21 Moosapet 34 | 22 DR_BRambedkar 35 | 23 Kukatpally 36 | 24 KPHBcolony 37 | 25 JNTUcollege 38 | 26 Miyapur 39 | 27 Sultanbazar 40 | 28 Narayanguda 41 | 29 Chikkadpali 42 | 30 RTCxroads 43 | 31 Musheerabad 44 | 32 Gandhihospital 45 | 33 SecundrabadWest 46 | 34 Paradeground 47 | 35 Nagole 48 | 36 Uppal 49 | 37 stadium 50 | 38 NGRI 51 | 39 Habsiguda 52 | 40 Tarnaka 53 | 41 Mettuguda 54 | 42 SecuderabadeEast 55 | 43 Paradise 56 | 44 Rasoolpura 57 | 45 PrakashNagar 58 | 46 Begumpet 59 | 47 MathuraNagar 60 | 48 Yusufguda 61 | 49 Jubliehills 62 | 50 JH-checkpost 63 | 51 Peddamagudi 64 | 52 Madhapur 65 | 53 Dugamcheruvu 66 | 54 Hitechcity 67 | 55 Raidurg 68 | 69 | -------------------------------------------------------------------------------- /dijkstras.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | #define INF 999 6 | int mindistance(int distance[],bool stat[]) 7 | { 8 | int minimum=INT_MAX,ind; 9 | for(int k=0;k<56;k++) 10 | { 11 | if(stat[k]==false && distance[k]<=minimum) 12 | { 13 | minimum=distance[k]; 14 | ind=k; 15 | } 16 | } 17 | return ind; 18 | } 19 | void dijkstra(int graph[56][56],int source, string stations[55]) 20 | { 21 | int distance[56]; 22 | bool stat[56]; 23 | for(int k=0;k<56;k++) 24 | { 25 | distance[k]=INT_MAX; 26 | stat[k]=false; 27 | } 28 | distance[source]=0; 29 | for(int k=0;k<56;k++) 30 | { 31 | int m=mindistance(distance,stat); 32 | stat[m]=true; 33 | for(int k=0;k<56;k++) 34 | { 35 | if(!stat[k] && graph[m][k] && distance[m]!=INT_MAX && distance[m]+graph[m][k]>source; 112 | dijkstra(graph,source,stations); 113 | return 0; 114 | } --------------------------------------------------------------------------------