Algorithms after Dijkstra and Kruskal for Big Data. User Manual

Similar documents
Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

COMP 355 Advanced Algorithms

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

International Journal of Advanced Research in Computer Science and Software Engineering

Review of Graph Theory. Gregory Provan

Chapter 4. Greedy Algorithms. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Lecture 10: Analysis of Algorithms (CS ) 1

Minimum Spanning Trees Shortest Paths

CSE 100 Minimum Spanning Trees Prim s and Kruskal

Chapter 9 Graph Algorithms

11/22/2016. Chapter 9 Graph Algorithms. Introduction. Definitions. Definitions. Definitions. Definitions

UNIT Name the different ways of representing a graph? a.adjacencymatrix b. Adjacency list

Chapter 9 Graph Algorithms

Chapter 9 Graph Algorithms

The minimum spanning tree problem

UNIT 5 GRAPH. Application of Graph Structure in real world:- Graph Terminologies:

Minimum-Spanning-Tree problem. Minimum Spanning Trees (Forests) Minimum-Spanning-Tree problem

Lecture 13. Reading: Weiss, Ch. 9, Ch 8 CSE 100, UCSD: LEC 13. Page 1 of 29

CSC 8301 Design & Analysis of Algorithms: Kruskal s and Dijkstra s Algorithms

UNIT 3. Greedy Method. Design and Analysis of Algorithms GENERAL METHOD

Dijkstra s algorithm for shortest paths when no edges have negative weight.

Announcements Problem Set 5 is out (today)!

CSE373: Data Structures & Algorithms Lecture 17: Minimum Spanning Trees. Dan Grossman Fall 2013

Algorithm Design Techniques. Hwansoo Han

Minimum Spanning Trees

Minimum Spanning Trees. Minimum Spanning Trees. Minimum Spanning Trees. Minimum Spanning Trees

Design and Analysis of Algorithms

Eulerian Cycle (2A) Walk : vertices may repeat, edges may repeat (closed or open) Trail: vertices may repeat, edges cannot repeat (open)

Classic Graph Theory Problems

Chapter 14. Graphs Pearson Addison-Wesley. All rights reserved 14 A-1

Undirected Graphs. Hwansoo Han

Minimum Spanning Tree

4.5 Minimum Spanning Tree. Minimo albero di copertura o ricoprimento

CSE 21: Mathematics for Algorithms and Systems Analysis

Graph Representation DFS BFS Dijkstra A* Search Bellman-Ford Floyd-Warshall Iterative? Non-iterative? MST Flow Edmond-Karp

Minimum Spanning Tree Of Undirected Graphs

Announcements. HW4 due Friday. Summer 2016 CSE373: Data Structures & Algorithms 1

of optimization problems. In this chapter, it is explained that what network design

CS350: Data Structures Dijkstra s Shortest Path Alg.

Theory of Computing. Lecture 10 MAS 714 Hartmut Klauck

A New Quick Algorithm for Finding the Minimal Spanning Tree

COMPSCI 311: Introduction to Algorithms First Midterm Exam, October 3, 2018

Chapter 14 Section 3 - Slide 1

Binary Relations McGraw-Hill Education

22 Elementary Graph Algorithms. There are two standard ways to represent a

Lecture Notes on Spanning Trees

Parallel Graph Algorithms

Info 2950, Lecture 16


Exam 3 Practice Problems

Parallel Graph Algorithms

Simple graph Complete graph K 7. Non- connected graph

CS200: Graphs. Rosen Ch , 9.6, Walls and Mirrors Ch. 14

4. GREEDY ALGORITHMS II

Algorithms. Algorithms 4.3 MINIMUM SPANNING TREES. introduction cut property edge-weighted graph API Kruskal s algorithm Prim s algorithm

Algorithms 4.3 MINIMUM SPANNING TREES. edge-weighted graph API greedy algorithm Kruskal's algorithm Prim's algorithm advanced topics

PATH FINDING AND GRAPH TRAVERSAL

ALGORITHM DESIGN GREEDY ALGORITHMS. University of Waterloo

We have already seen the transportation problem and the assignment problem. Let us take the transportation problem, first.

Lecture 19 Shortest Path vs Spanning Tree Max-Flow Problem. October 25, 2009

Module 2: NETWORKS AND DECISION MATHEMATICS

Lecture 25 Notes Spanning Trees

Chapter 9. Greedy Technique. Copyright 2007 Pearson Addison-Wesley. All rights reserved.

CSE332: Data Abstractions Lecture 25: Minimum Spanning Trees. Ruth Anderson via Conrad Nied Winter 2015

Graph Theory. Part of Texas Counties.

Further Mathematics 2016 Module 2: NETWORKS AND DECISION MATHEMATICS Chapter 9 Undirected Graphs and Networks

Routing. Information Networks p.1/35

CMPUT 396 Sliding Tile Puzzle

Outline. Introduction. Representations of Graphs Graph Traversals. Applications. Definitions and Basic Terminologies

Graphs and Network Flows ISE 411. Lecture 7. Dr. Ted Ralphs

Lecture 19. Broadcast routing

Biological Networks Analysis

Approximation Algorithms

CIS 121 Data Structures and Algorithms Minimum Spanning Trees

Lecture 1. Introduction

Algorithm Design (8) Graph Algorithms 1/2

Lecture 25 Spanning Trees

Introduction to Computer Science

Graphs and Network Flows IE411. Lecture 21. Dr. Ted Ralphs

Graphs. The ultimate data structure. graphs 1

Graphs. The ultimate data structure. graphs 1

Week 9. CS 400 Programming III

Algorithms and Theory of Computation. Lecture 5: Minimum Spanning Tree

Algorithms and Theory of Computation. Lecture 5: Minimum Spanning Tree

Week 11: Minimum Spanning trees

International Journal of Computer Engineering and Applications, Volume XII, Special Issue, July 18, ISSN

Algorithms. Algorithms 4.3 MINIMUM SPANNING TREES. introduction cut property edge-weighted graph API Kruskal s algorithm Prim s algorithm context

Spanning Tree. Lecture19: Graph III. Minimum Spanning Tree (MSP)

MST & Shortest Path -Prim s -Djikstra s

CS4800: Algorithms & Data Jonathan Ullman

A quick review. The clustering problem: Hierarchical clustering algorithm: Many possible distance metrics K-mean clustering algorithm:

CS171 Introduction to Computer Science II. Graphs

Chalmers University of Technology. Network Models. April 11, Birgit Grohe

Network Models - Examples. Network Models. Definition and Terminology. The Minimum Spanning Tree (MST) Problem

CSE 100: GRAPH ALGORITHMS

Minimal Spanning Tree

NP Completeness. Andreas Klappenecker [partially based on slides by Jennifer Welch]

Pred 8 1. Dist. Pred

Transcription:

Algorithms after Dijkstra and Kruskal for Big Data User Manual Ovak Technologies 2016

Contents 1. Introduction... 3 1.1. Definition and Acronyms... 3 1.2. Purpose... 3 1.3. Overview... 3 2. Algorithms... 4 2.1. Description of Dijkstra s Algorithm... 4 2.2. Description of Kruskal s Algorithm... 5 3. Architecture... 5 4. Examples... 7 5. LabVIEW Features and Concepts Used... 8 6. Support Information... 9 2

1. Introduction 1.1. Definition and Acronyms Graph in mathematics, and more specifically in graph theory, a graph is a representation of a set of objects where some pairs of objects are connected by links. The interconnected objects are represented by mathematical abstractions called vertices (also called nodes or points), and the links that connect some pairs of vertices are called edges (also called arcs or lines). Tree in mathematics, and more specifically in graph theory, a tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any acyclic connected graph is a tree. Spanning Tree in the mathematical field of graph theory, a spanning tree T of an undirected graph G is a sub graph that includes all of the vertices of G that is a tree. Minimum Spanning Tree (MST) a minimum spanning tree is a spanning tree of a connected, undirected graph. It connects all the vertices together with the minimal total weighting for its edges. A single graph can have many different spanning trees. Graph s Path in graph theory, a path in a graph is a finite or infinite sequence of edges, which connect a sequence of vertices that, by most definitions, are all distinct from one another. Source Node here source node is a node, where the path begins. Destination Node here destination node is a node, where the path ends. NP-hardness non-deterministic polynomial-time hard. 1.2. Purpose This document is designed to provide necessary information to LabVIEW developers of how to use «Algorithms after Dijkstra and Kruskal for Big Data» toolkit. 1.3. Overview The word «graph» was first used in this sense by J. J. Sylvester in 1878. Graphs are the basic subject studied by graph theory. In the most common sense of the term, a graph is an ordered pair G = (V, E) comprising a set V of vertices, nodes or points together with a set E of edges, arcs or lines, which are 2- element subsets of V (i.e. an edge is related with two vertices, and the relation is represented as an unordered pair of the vertices with respect to the particular edge). To avoid ambiguity, this type of graph may be described precisely as undirected and simple. There are many algorithms for graphs, and two of them are used in this toolkit. They are Dijkstra s algorithm and Kruskal s algorithm. 3

Dijkstra s algorithm is used to find the shortest path between two nodes in graph, which may represent, for example, road networks. For a given source node in the graph, the algorithm finds the shortest path between that node (source node) and any other (destination node). Kruskal s algorithm is used to find the minimum spanning tree of graph. MST problem is to find connected graph G with positive edge weights, find a minimum weight set of edges that connects all of the vertices. It is a greedy algorithm in graph theory as it finds a minimum spanning tree for a connected weighted graph adding increasing cost arcs at each step. The «Algorithms after Dijkstra and Kruskal for Big Data» enables to find the shortest path between two points. The shortest path problems form the foundation of an entire class of optimization problems that can be solved by a technique called Column Generation. Examples include vehicle routing problem, survivable network design problem, find the shortest path from machine A to machine B among others. This tool also enables to find MST of graph. MST is a fundamental problem with diverse applications: 1. Network design Telephone, electrical, hydraulic, TV cable, computer, road. 2. Approximation algorithms for NP-hardness problems Traveling salesperson problem, Steiner tree 3. Indirect applications Max bottleneck paths LDPC codes for error correction Image registration with Renyi entropy Learning salient features for real-time face verification Reducing data storage in sequencing amino acids in a protein Model locality of particle interactions in turbulent fluid flows Autoconfig protocol for Ethernet bridging to avoid cycles in a network 4. Cluster analysis «K» clustering problem can be viewed as finding a MST and deleting the «K-1» most important edges. This tool is mostly used for big data, enabling to find the shortest path between two nodes and the minimum spanning tree of graph very fast and easy. 2. Algorithms 2.1. Description of Dijkstra s Algorithm 1. Assign to every node a tentative distance value: set it to zero for our initial node and to infinity for all other nodes. 2. Set the initial node as current. Mark all other nodes unvisited. Create a set of all the unvisited nodes called the unvisited set. 4

3. For the current node, consider all of its unvisited neighbors and calculate their tentative distances. Compare the newly calculated tentative distance to the current assigned value and assign the smaller one. For example, if the current node A is marked with a distance of 6, and the edge connecting it with a neighbor B has length 2, then the distance to B (through A) will be 6 + 2 = 8. If B was previously marked with a distance greater than 8 then change it to 8. Otherwise, keep the current value. 4. When we are done considering all of the neighbors of the current node, mark the current node as visited and remove it from the unvisited set. A visited node will never be checked again. 5. If the destination node has been marked visited (when planning a route between two specific nodes) or if the smallest tentative distance among the nodes in the unvisited set is infinity (when planning a complete traversal; occurs when there is no connection between the initial node and remaining unvisited nodes), then stop. The algorithm has finished. 6. Otherwise, select the unvisited node that is marked with the smallest tentative distance, set it as the new "current node", and go back to step 3. Dijkstra's algorithm enables to determine the shortest distance between two nodes, while «Algorithms after Dijkstra and Kruskal for Big Data» finds the edges (or the nodes), through which passes the shortest path and displays that path on the picture. 2.2. Description of Kruskal s Algorithm 1. Sort all the edges in non-decreasing order of their weight. 2. Pick the smallest edge. Check if it forms a cycle with the spanning tree formed so far. If cycle is not formed, include this edge. Else, discard it. 3. Repeat step 2 until there are (V-1) edges in the spanning tree. V is the amount of nodes. Kruskal s algorithm, enables to give the edges of minimum spanning tree, and shows the minimum spanning tree on picture. 3. Architecture Graphs Algorithms. Lvlib library contains two libraries: Dijktra s Algorithm.lvlib and Kruskal s Algorithm.lvlib. 1. Dijkstra s Algorithm.lvlib library contains six VIs: Shortest path.vi contains the main code. Choose minimum.vi returns the shortest distance for all destination nodes, and finds the next node that should be visited. Get picture.vi returns the picture of graph and shows the shortest path between source node and destination node. Initialize arrays.vi creates arrays of graph's edges and the lengths of edges. Initialize arrays.vi returns true, if the lengths' values are correct (positive number). It returns false, if the lengths' value is negative number or zero. 5

Rebuild array.vi for the current node, considers all of its unvisited neighbors and calculates their tentative distances. It compares the new calculated tentative distance to the current assigned value and assigns the smaller one. For example, if the current node A is marked with a distance of 6, and the edge connecting it with a neighbor B has length 2, then the distance to B (through A) will be 6 + 2 = 8. If B has been previously marked with a distance greater than 8 then change it to 8. Otherwise, keep the current value. The edges of the shortest path.vi finds the shortest distance between source node and destination node, and returns the shortest path. 2. Kruskal s Algorithm.lvlib library contains four VIs: Minimal spanned tree.vi contains the main code. Delete unnecessary items.vi deletes loops (e.g., AA) and similar items (e.g., AB, BA). Identify next edge.vi returns true if the edges generate loop, if not returns false (e.g., AB-BC-AC is a loop). Loop.vi determines whether the path is a loop for 3 edges or not. Figure 1 Graphs Algorithms library 6

4. Examples 1. Dijktra s algorithm Complete the following steps to run this example: 1. In the Project Explorer window, open Example Dijktra s.vi. 2. Enter Array of Edges and their lengths, Array of Nodes, Node 1 and Node 2 parameters (if these parameters are not entered, the VI will work with default parameters). 3. Click RUN button. Figure 2 Dijkstra s Algorithm Block Diagram Figure 3 Dijkstra s Algorithm Front Panel 2. Kruskal s algorithm Complete the following steps to run this example: 1. In the Project Explorer window, open Example Kruskal s.vi. 7

2. Enter Array of Edges and their lengths and Array of Nodes parameters (if these parameters are not entered, the VI will work with default parameters). 3. Click RUN button. Figure 4 Kruskal s Algorithm Block Diagram Figure 5 Kruskal s Algorithm Front Panel 5. LabVIEW Features and Concepts Used Case structures Clusters Arrays Enums Shift registers While Loops For Loops State machines String Functions Picture Functions 8

6. Support Information For technical support, please, contact Ovak Technologies at: Phone: + 374 10 21-97-68 Email: support@ovaktechnologies.com Web: www.ovaktechnologies.com 9