Presentation is loading. Please wait.

Presentation is loading. Please wait.

GRAPH ALGORITHMS AND DATABASES Dušan Zeleník. Common Tasks  Sorting  Searching  Inferring  Routing.

Similar presentations


Presentation on theme: "GRAPH ALGORITHMS AND DATABASES Dušan Zeleník. Common Tasks  Sorting  Searching  Inferring  Routing."— Presentation transcript:

1 GRAPH ALGORITHMS AND DATABASES Dušan Zeleník

2 Common Tasks  Sorting  Searching  Inferring  Routing

3 Entities and their properties  Single attribute entities  Simple ordinal values  Relatively easy to sort or search  Low complexity  Indexing  Multi attribute entities  Relations among entities  Calculating distances (similarity)  Discovering properties

4 Trees and Graphs  Tree is a graph  Balancing  Lowering the complexity ( O(log n) )  Graph  Triplets (S - P - O)  Complex structure with properties Polynomial compelxity ( O(n^k) )

5 Spreading Activation  Select initial nodes and fill them with energy  Spread energy from nodes  Split energy among associated nodes  Mark nodes as already used  Do not spread if energy is under threshold  Repeat spreading until convergence

6 Page Rank  Each node receives initial rank  Count outgoing edges C(node)  Page Rank for Node A is PR(A) = =(1- d) + d (PR(T1)/C(T1) +... + PR(Tn)/C(Tn)) PR(A) is the PageRank of page A, PR(Ti) is the PageRank of pages Ti which link to page A, C(Ti) is the number of outbound links on page Ti d is a damping factor which can be set between 0 and 1.

7 Neo4J Database  Java  SPARQL, cypher, gremlin  ACID  Multiplatform  Opensource  Plugins  Already implements many algorithms  REST

8 Neo4J Hello World Node f = graphDb.createNode(); f.setProperty("message","Hello"); Node s = graphDb.createNode(); s.setProperty("message","World!"); Relationship r = f.createRelationshipTo(s, RelTypes.KNOWS ); r.delete(); f.delete(); s.delete();

9 Neo4J Graph Algorithms PathFinder finder = GraphAlgoFactory.dijkstra ( Traversal.expanderForTypes ( ExampleTypes.MY_TYPE, Direction.BOTH ), "cost" ); WeightedPath path = finder.findSinglePath( nodeA, nodeB ); path.weight();

10 Neo4J Plugin public class ShortestPath extends ServerPlugin { @Description( "Find the shortest path between two nodes." ) @PluginTarget( Node.class ) public Iterable shortestPath(@Source Node source, @Parameter( name = "target" ) Node target, @Parameter( name = "types", optional = true ) String[] types, @Parameter( name = "depth", optional = true ) Integer depth ) { Expander expander; if ( types == null ) expander = Traversal.expanderForAllTypes(); else { expander = Traversal.emptyExpander(); for ( int i = 0; i < types.length; i++ ) expander = expander.add( DynamicRelationshipType.withName( types[i] ) ); } PathFinder shortestPath = GraphAlgoFactory.shortestPath( expander, depth == null ? 4 : depth.intValue() ); return shortestPath.findAllPaths( source, target ); } curl -X POST http://localhost:7474/db/data/ext/GetAll/node/123/shortestPath \ -H "Content-Type: application/json" \ -d '{"target":"http://localhost:7474/db/data/node/456&depth=5"}'http://localhost:7474/db/data/node/456&depth=5

11 Research and Graphs  Z. Huang, W. Chung, T.-H. Ong, and H. Chen, “A graphbased recommender system for digital library,” in Proceedings of the 2nd ACM/IEEE-CS joint conference on Digital libraries, ser. JCDL ’02. New York, NY, USA: ACM, 2002, pp. 65–73.  I. Mele, F. Bonchi, and A. Gionis, “The early-adopter graph and its application to web-page recommendation.” New York, New York, USA: ACM Press, 2012, p. 1682.  S. D. Kamvar, T. H. Haveliwala, C. D. Manning, and G. H. Golub, “Extrapolation methods for accelerating pagerank computations,” in Proceedings of the 12th international conference on World Wide Web, ser. WWW ’03. New York, NY, USA: ACM, 2003, pp. 261–270.  Y. Deng, Z. Wu, C. Tang, H. Si, H. Xiong, and Z. Chen, “A Hybrid Movie Recommender Based on Ontology and Neural Networks.” Ieee, Dec. 2010, pp. 846–851.  B. Chen, J. Wang, Q. Huang, and T. Mei, “Personalized video recommendation through tripartite graph propagation.” New York, New York, USA: ACM Press, 2012, p. 1133.


Download ppt "GRAPH ALGORITHMS AND DATABASES Dušan Zeleník. Common Tasks  Sorting  Searching  Inferring  Routing."

Similar presentations


Ads by Google