intro-to-ibm-graph



intro-to-ibm-graph

1 1


intro-to-ibm-graph


On Github ukmadlz / intro-to-ibm-graph

/ ukmadlz

Introduction to IBM Graph

Who am I?

Mike Elsmore

Developer Advocate

mike.elsmore@uk.ibm.com

@ukmadlz

Where to start?

  • What are Graphs?
  • Why would you use Graphs?
  • What's IBM Graph?
  • How would you use IBM Graph?

What are Graphs?

Initial Thoughts

ID Name DateOfBirth 1 Person A 01 Jan 1980 2 Person B 20 Oct 1983 3 Person C 13 Apr 1979 4 Person D 05 May 2004 5 Person E 24 Feb 2010

Graph Network Theory

https://en.wikipedia.org/wiki/Network_theory

https://en.wikipedia.org/wiki/Graph_theory

Brief Description

Storing and modeling data as vertices/nodes and the interconnected edges. Representing discrete data points as vertices and the relationships between them as edges

Previous example

ID Name DateOfBirth 1 Person A 01 Jan 1980 2 Person B 20 Oct 1983 3 Person C 13 Apr 1979 4 Person D 05 May 2004 5 Person E 24 Feb 2010

Vertex?

Discrete data points

Edge?

The relationship between discrete data points

Traversal

Moving between different data points in side the Graph for insights

Traversal Example

1 Step Traversal

Give me all vertices that are 1 edge/relationship away from Person A

[
  ["Person A",
  "spouse",
  "Person B"],
  ["Person A",
  "guardian of",
  "Person D"]
]
    

2 Step Traversal

Give me all vertices that are 2 edge/relationship away from Person A

[
  ["Person A",
  "spouse",
  "Person B",
  "spouse",
  "Person C"],
  ["Person A",
  "spouse",
  "Person B",
  "guardian of",
  "Person E"]
]
    

Why would you use Graphs?

Social Graphs

aka Social Networks

https://en.wikipedia.org/wiki/Social_graph https://en.wikipedia.org/wiki/Erd%C5%91s_number

Demo: http://bacon.mybluemix.net/

Recommendation Engines

Matching items to other items based on the relationships between them

Demo: http://rk-graph.mybluemix.net/

Fraud Detection

Detecting patterns that don't follow normal trends

Large Scale Relational Problems

Read queries that are likely to use a lot of memory or table lock for a prolonged time

What's IBM Graph?

Based on TinkerPop3

The Stack

HTTP
RESTful
API
> >

How to use IBM Graph?

Available via IBM Bluemix

https://console.ng.bluemix.net/catalog/services/ibm-graph/

https://console.eu-gb.bluemix.net/catalog/services/ibm-graph/

How to interact with IBM Graph

  • No access to the Gremlin binary protocol
  • Via the HTTP API
  • If you can Curl or make a HTTP request you can use it

Endpoints

  • /vertices to manage vertices
  • /edges to manage edges
  • /gremlin to query with gremlin queries
  • /index to manage indexes
  • /schema to create and view all existing indexes

Vertices

Make POST, PUT, GET & DELETE queries to manipulate the vertices

https://ibm-graph-docs.ng.bluemix.net/api.html#vertex-apis

Example:

curl $GRAPHURL/vertices -X POST -H "Content-Type: application/json" -d "{ \"key1\":\"A\", \"key2\":\"B\" }"

Edges

Make POST, PUT, GET & DELETE queries to manipulate the edges

https://ibm-graph-docs.ng.bluemix.net/api.html#edge-apis

Example:

curl $GRAPHURL/edges -X POST -H "Content-Type: application/json" -d "{ \"outV'": 256, \"label\": \"knows\", \"inV\": 512 }"

Indexes

Make POST, PUT, GET & DELETE queries to manipulate the indexes

https://ibm-graph-docs.ng.bluemix.net/api.html#index-apis

Example:

curl $GRAPHURL/index?type=vertex -X POST -H "Content-Type: application/json" -d "{ \"type\": \"vertex\", \"propertyKeys'": [{\"name\": \"personName\", \"dataType\": \"String\", \"cardinality\": \"SINGLE\"}], \"indexOnly\": {\"name\": \"person\"}, \"composite\": true, \"name\": \"vByPerson\"}"

Schemas

Make POST & GET queries to manipulate the schemas

https://ibm-graph-docs.ng.bluemix.net/api.html#schema-apis

Example:

curl $GRAPHURL/schema -X POST -H "Content-Type: application/json" -d "{ \"edgeindexes\": [], \"edgelabels\": [ {\"multiplicity\":\"simple\", \"name\":\"r\"} ], \"propertykeys\": [ {\"cardinality\":\"single\", \"datatype\":\"string\", \"name\":\"c\"} ], \"vertexindexes\": [ {\"composite\":false, \"name\":\"ci\", \"propertykeys\":[ \"c\" ], \"unique\":false} ], \"vertexlabels\": [ {\"name\": \"l\"} ] }"

Gremlin

Make POST queries to manipulate your entire Graph

https://ibm-graph-docs.ng.bluemix.net/api.html#gremlin-apis

Example:

curl $GRAPHURL/gremlin -X POST -H "Content-Type: application/json" -d "{\"gremlin\": \"def g = graph.traversal(); g.V(256).out().out()\"}"

Example

Example of Gremlin in Social Graphs

http://bacon.mybluemix.net/

Slides

http://bit.ly/intro-to-ibm-graph

Questions?

mike.elsmore@uk.ibm.com

@ukmadlz

© IBM Corporation 2016. All Rights Reserved.