Chuck Olson Software Engineer October 2015 Graph Databases and Java 1.

Slides:



Advertisements
Similar presentations
Decision Maths Networks Kruskals Algorithm Wiltshire Networks A Network is a weighted graph, which just means there is a number associated with each.
Advertisements

Problem solving with graph search
Neo4j. План Cypher – Создание – Запросы Neo4j embedded in Java Немного о релизации (Neo4j Internals) – Native Graph Processing – Native Graph Storage.
1 Abdeslame ALILAOUAR, Florence SEDES Fuzzy Querying of XML Documents The minimum spanning tree IRIT - CNRS IRIT : IRIT : Research Institute for Computer.
IKI 10100: Data Structures & Algorithms Ruli Manurung (acknowledgments to Denny & Ade Azurat) 1 Fasilkom UI Ruli Manurung (Fasilkom UI)IKI10100: Lecture10.
Breadth-First Search Seminar – Networking Algorithms CS and EE Dept. Lulea University of Technology 27 Jan Mohammad Reza Akhavan.
Graphs Chapter 12. Chapter Objectives  To become familiar with graph terminology and the different types of graphs  To study a Graph ADT and different.
Introduction to Databases
ITEC200 – Week 12 Graphs. 2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study.
NOSQL Graph Database and Neo4j Presented by: Zuping Li Xiaoxiao Jiang Peter Neubauer on May 12, 2010.
Visual Web Information Extraction With Lixto Robert Baumgartner Sergio Flesca Georg Gottlob.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Spring 2010CS 2251 Graphs Chapter 10. Spring 2010CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs.
Minimum Spanning Trees CIS 606 Spring Problem A town has a set of houses and a set of roads. A road connects 2 and only 2 houses. A road connecting.
1 Routing Algorithms. 2 Outline zBellaman-Ford Algorithm zDijkstra Algorithm.
Fall 2007CS 2251 Graphs Chapter 12. Fall 2007CS 2252 Chapter Objectives To become familiar with graph terminology and the different types of graphs To.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
Lecture 25 CSE 331 Nov 2, Adding teeth to group talk Form groups of size at most six (6) Pick a group leader I will ask group leader(s) to come.
Graphs & Graph Algorithms 2 Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Lecture 27 CSE 331 Nov 6, Homework related stuff Solutions to HW 7 and HW 8 at the END of the lecture Turn in HW 7.
Graph databases …the other end of the NoSQL spectrum. Material taken from NoSQL Distilled and Seven Databases in Seven Weeks.
Create Forms Lesson 5. Software Orientation Creating Forms A form is a database object –enter, edit, or display data from a table or query Providing.
Shortest Path Problems Dijkstra’s Algorithm TAT ’01 Michelle Wang.
Neo4j Sarvesh Nagarajan TODO: Perhaps add a picture here.
Object and object-relational databases 1. Object databases vs. Object-relational databases Object databases Stores complex objects – Data + functions.
Geek Night Nima Ben Tramchester & Graph Databases.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms: Minimum.
Using Dijkstra’s Algorithm to Find a Shortest Path from a to z 1.
Operations Research Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD4207 University of Palestine.
Networks and the Shortest Path Problem.  Physical Networks  Road Networks  Railway Networks  Airline traffic Networks  Electrical networks, e.g.,
COMP5338 – Advanced Data Models
Dijkstra’s Algorithm. Announcements Assignment #2 Due Tonight Exams Graded Assignment #3 Posted.
Network and Communications Ju Wang Chapter 5 Routing Algorithm Adopted from Choi’s notes Virginia Commonwealth University.
COMP5338 – Advanced Data Models
26 Mar 04 1 Application Software Practical 5/6 MS Access.
L3-Network Algorithms L3 – Network Algorithms NGEN06(TEK230) – Algorithms in Geographical Information Systems by: Irene Rangel, updated Nov by Abdulghani.
Graphs A ‘Graph’ is a diagram that shows how things are connected together. It makes no attempt to draw actual paths or routes and scale is generally inconsequential.
1 MS Access. 2 Database – collection of related data Relational Database Management System (RDBMS) – software that uses related data stored in different.
Union-Find  Application in Kruskal’s Algorithm  Optimizing Union and Find Methods.
Graphs Chapter 12. Chapter 12: Graphs2 Chapter Objectives To become familiar with graph terminology and the different types of graphs To study a Graph.
Discrete Optimization Lecture 4 – Part 1 M. Pawan Kumar
Decision Maths 1 Shortest path algorithm Dijkstra’s Algorithm A V Ali :
CHAPTER 13 GRAPH ALGORITHMS ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
Graphs Definition: a graph is an abstract representation of a set of objects where some pairs of the objects are connected by links. The interconnected.
Po-Lung Chen (Dont block me) d091: Urban Transport System 2010/03/26 (1) d091: Urban Transport System Po-Lung Chen Team Dont Block Me, National Taiwan.
Graph Database - Neo4j ISQS3358, Spring Graph Database A graph database is a database that uses graph structures for semantic queries with nodes,
Spanning Trees Dijkstra (Unit 10) SOL: DM.2 Classwork worksheet Homework (day 70) Worksheet Quiz next block.
FACIAL RE-RECOGNITION Jared Beekman Mentor: Dr. Paul Bender.
GUILLOU Frederic. Outline Introduction Motivations The basic recommendation system First phase : semantic similarities Second phase : communities Application.
Dive into NoSQL with Azure Niels Naglé Hylke Peek.
Graphs - II CS 2110, Spring Where did David leave that book? 2.
Neo4j: GRAPH DATABASE 27 March, 2017
Week 7 - Monday CS 113.
Web Routing Designing an Interface
Every Good Graph Starts With
Graph Database.
Greedy Algorithms / Minimum Spanning Tree Yin Tat Lee
Chapter 2 Database Environment.
Short paths and spanning trees
Graphs & Graph Algorithms 2
Route Optimization Problems and Google Maps
Graphs Chapter 11 Objectives Upon completion you will be able to:
Networks Kruskal’s Algorithm
A Very Brief Introduction to Relational Databases
Shortest Paths.
Minimum spanning trees
Implementation of Dijkstra’s Algorithm
Shortest Path Solutions
Prim’s algorithm for minimum spanning trees
Presentation transcript:

Chuck Olson Software Engineer October 2015 Graph Databases and Java 1

Outline  Assumptions  What is a graph and what are they good for?  What is a graph database?  What is Neo4J and how does one use it?  Case: Subway Model Results Compilation  Questions 2

Audience Assumptions Working knowledge of:  Java  Relational databases 3

What is a graph?  Collection of nodes and edges  Edges can be directed (or not)  Edges can represent many things 4 Chuck Jim Jay Gary Knows Coco Annoys

What is a graph? 5

Transportation Example 6 Denver 18:00 20:00 13:00 15:00 12:00 Los Angeles Chicago New York Dallas 16:00 17:00

What are graphs good for?  Often map more directly to the structure of some object-oriented problems.  Work best for storing “richly connected” data  Many algorithms exist to extract useful information – Dijkstra’s shortest path – Minimum spanning tree (Kruskal and others) 7

What is a graph database?  A NoSQL database that stores nodes and edges, and provides a mechanism to easily query information from it.  Can contain nodes of different types  Can have free-form attributes within nodes  Can have edges (relationships) of different types  Can have attributes attached to edges (distance, cost, relationship)  Query mechanism 8

Why would I ever use one?  Easier to find solutions to certain problems by framing data graphically.  “The right tool for the job” 9

Neo4J  Open source (GPLv3 for Community Edition)  V1.0 released in 2010  Written in Java and Scala  Managed by Neo Technology  Uses the Property Graph Model  Embedded or server  Fully transactional  Set of jar files ~30MB  Query language: Cypher 10

How do you use Neo4J?  Creating a database 11 // Location of database String dbPath = “/Users/chuck/myneodb”; GraphDatabaseFactory factory = new GraphDatabaseFactory(); GraphDatabaseBuilder builder = factory.newEmbeddedDatabaseBuilder(dbPath); GraphDatabaseService dbService = builder.newGraphDatabase();

How do you use Neo4J?  Creating fixed node and edge types 12 // Node types public enum NodeLabel implements Label {Station}; // Relationship types public enum RelType implements RelationshipType {TRACKS_TO, ROUTE_TO, AIRWAY_TO};

How do you use Neo4J?  Adding nodes to a database 13 // Create Station node Node node1 = dbService.createNode(NodeLabel.Station); // Set properties on the Station node1.setProperty("number", “100”); node1.setProperty("name", “State St”); // Add another Node node2 = dbService.createNode(NodeLabel.Station); node2.setProperty("number", “101”); node2.setProperty("name", “Lake St”);

How do you use Neo4J?  Adding edges to a database 14 // Create edge from node1 to node2 Relationship edge = node1.createRelationshipTo(node2, RelType.ROUTE_TO); // Set props on the edge edge.setProperty("route", “State St Subway”); edge.setProperty("line", “Red”); // Create another edge of a different type. edge = node1.createRelationshipTo(node2, RelType.TRACK_TO);

How do you use Neo4J?  Querying the database 15 // Returns station numbers of all stations in graph. String queryText = “MATCH (stn:Station) RETURN stn.number"; ExecutionEngine engine = new ExecutionEngine(dbService); ExecutionResult result = engine.execute(queryText); Iterator stnIt = result.columnAs("stn.number"); // Print results while (stnIt.hasNext()) System.out.println(stnIt.next());

Case: Studying Subways 16

Case: Studying Subways Questions we might want to ask:  “Find all the stations that have air connectivity paths to station X that are less than K km”  “Find all the train routes that that go through all stations that are N stops from station X” 17

Case: Studying Subways 18

Case: Studying Subways 19 Stations - Number (id) - Name - Lat - Lon Segments - SegmentId (id) - StationFromNumber - StationToNumber - Length - SegmentType SegmentTypes - SegmentTypeId (id) - TypeName LineSegments - LineId (id) - SegmentId - SegmentIndex Lines - LineId (id) - LineName - LineDirection Relational attempt…

Case: Studying Subways 20 Station Name Station Number Route Name Distance Graph attempt… Node ROUTE_TO Edge TRACKS_TO Edge AIRWAY_TO Edge

Case: Studying Subways 21 St. Paul’s 100 Bank 101 Cannon Street 200 Monument 201 Tower Hill 202 Tower Gateway 300 Red Green Yellow 1 km.7 km.2 km 1.8 km Green Yellow.1 km White/Blue

Case: Studying Subways  Answering the question: returns all stations 2 track segments from station 200 (Cannon Street) 22 MATCH p=(fromStn:Station)-[edge:TRACKS_TO*2..2]- (toStn:Station {number:‘200’}) WHERE fromStn.number <> toStn.number RETURN distinct fromStn,toStn,fromStn.number

Drawbacks  No standard query language like SQL. Vendor-specific.  Query language learning curve.  Lack of built-in visualization tools. 23

For Further Reading… 24 Ian Robinson, Jim Webber, Emil Eifrem Graph Databases, 2 nd Edition O’Reilly and Associates Rik Van Bruggen Learning Neo4J Packt Publishing

Questions 25