140 likes | 314 Views
Dijkstra’s Algorithm. Terminology. Graph (G) : A set of items connected by edges. Each item in a graph is called a vertex or edge. Vertex (V) : An item in a graph, sometimes referred to as a node. (A node is a unit of reference in a data structure.)
E N D
Terminology • Graph (G) : A set of items connected by edges. Each item in a graph is called a vertex or edge. • Vertex (V) : An item in a graph, sometimes referred to as a node. (A node is a unit of reference in a data structure.) • Edge (E) : A connection between two vertices of a graph. • Weighted Graph : A graph which has a weight, or number, associated with each edge.
Dijkstra’s Algorithm is… • Named after it’s creator E.W. Dijkstra. He is a Professor of Mathematic at the University of Amsterdam. • An algorithm for finding the shortest path between two vertices (or nodes). This algorithm has the added benefit of finding the shortest path from a given source to all points in the graph at the same time. Because of this it is sometimes referred to as the single-source shortest path algorithm • Requires all edged weights to be positive. • Its time efficiency is O (E log V).
Step 1 Dijkstra’s Algorithm A can see B and C B WINS WITH A COST OF 30!
Step 2 Dijkstra’s Algorithm B can see C and D C WINS WITH A COST OF 40!
Step 3 Dijkstra’s Algorithm C can see D and E E WINS WITH A COST OF 50!
Step 4 Dijkstra’s Algorithm E sees nothing… However, other nodes are seen from previously seen vertices.
Dijkstra’s Algorithm is GREEDY! • A Greedy Algorithm is defined as follows: • An algorithm that always takes the best immediate or local, solution while finding an answer. Greedy algorithms find the overall or globally optimal solution.
Warshall’s Algorithm O (V3) Floyd’s Algorithm O (V3) Dijkstra’s Algorithm O (E Log V) Dijkstra WINS!!!
Group D Presentation 1)Warshall’s Algorithm 2)Floyd’s Algorithm 3)Dijkstra’s Algorithm Prepared by: Michael Cicarella Gabriela Ruz Marius Janusaitis