Giter VIP home page Giter VIP logo

one_direction's Introduction

One Direction

Stored Procedure in Neo4j 4.1.x

Instructions

This project uses maven, to build a jar-file with the procedure in this project, simply package the project with maven:

mvn clean package

This will produce a jar-file, target/one_direction-1.0-SNAPSHOT.jar, that can be copied to the plugin directory of your Neo4j instance.

cp target/one_direction-1.0-SNAPSHOT.jar neo4j-enterprise-4.1.X/plugins/.

In the "neo4j.conf" file inside the Neo4j/conf folder add this line:

dbms.security.procedures.unrestricted=com.maxdemarzi.*

The purpose of this procedure is to find paths between two nodes where we change direction no more than once.

Stored Procedures:

// YIELD path 
CALL com.maxdemarzi.one.direction(start, end, types, length); 

// Example using sample data
MATCH (u1:User { name: 'max' } ), (u4:User { name: 'luke' } ) WITH u1, u4 
CALL com.maxdemarzi.one.direction(u1, u4, 'KNOWS, LIKES', 5) 
YIELD path 
RETURN count(path) AS count;

Sample data:

CREATE (u1:User { name: 'max' } )
CREATE (u2:User { name: 'alex' } )
CREATE (u3:User { name: 'michael' } )
CREATE (u4:User { name: 'luke' } )
CREATE (u5:User { name: 'mark' } )
CREATE (u6:User { name: 'david' } )
CREATE (u7:User { name: 'yufei' } )
// 1 > 2 > 3 > 4 (Valid)
CREATE (u1)-[:KNOWS]->(u2)
CREATE (u2)-[:KNOWS]->(u3)
CREATE (u3)-[:KNOWS]->(u4)
// 1 > 2 < 5 < 4 (Valid)
CREATE (u2)<-[:LIKES]-(u5)
CREATE (u5)<-[:LIKES]-(u4)
// 1 > 2 < 6 > 4 (Invalid)
CREATE (u2)<-[:KNOWS]-(u6)
CREATE (u6)-[:KNOWS]->(u4)
// 1 > 2 < 6 < 8 (Invalid due to rel type)
CREATE (u5)<-[:HATES]-(u4)       


// One Filter
CALL com.maxdemarzi.boolean.filter("Order", {not:false, and:[
    {property: "color", values: ["Blue"], not: false}
]}, 10) 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.