Shortest Path from source to Vertex :- Dijkstra Algorithm:- Dijkstra Algorithms is an algorithm use to find the shortest path from source vertex to a given vertex. package Graph ; import java.util.HashMap ; abstract public class DirectedGraph { Vertex [] vertexlist = new Vertex [ 10 ]; HashMap < Character , HashMap < Character , Integer >> edgelist = new HashMap <>(); Vertex vertex ; //count of vertex and edge static int vertexcount = 0 ; int edgecount = 0 ; /* * This function takes a label and insert in the vertex list as well as edge list since it is new vertex it will add * null to its adjoining vertices */ int addVertex ( char label ) { vertex = new Vertex ( label ); vertexlist [ vertexcount ]= vertex ; System . out . println ( vertexlist [ vertexcount ]. label ); edgelist . put ( vertex . label , null ); vertexcount ++; return vertexcount ; } int addEdge ( char label , char []

## Comments

## Post a Comment