Giter VIP home page Giter VIP logo

neo4j-demo's Introduction

neo4j-demo

Some common tasks can be done by neo4j.

Query City Graph

Step of Demo (on Windows)

  1. Install neo4j and start server.
  • Download: https://neo4j.com/download/ You will get an exe file: neo4j-desktop-1.0.4-setup.exe.
  • Just install exe. It may require you to login with some SNS account (like google account)
  • Use the neo desktop to create a LOCAL database. LOCAL database don't need username/password. And start the database server.
  1. Prepare data using below statements.
  • Open created database and click manage->Open Browser. screenshot
  • Execute below cypher statments to prepare data.
CREATE (beijing: City {name:"beijing"} ),
(shanghai: City {name:"shanghai"} ),
(qingdao: City {name:"qingdao"} ), 
(zhengzhou: City {name:"zhengzhou"} ), 
(xining: City {name:"xining"} ),
(xian: City {name:"xian"} ),
(xiamen: City {name:"xiamen"} ),
(guangzhou: City {name:"guangzhou"} ),
(zhuhai: City {name:"zhuhai"} ),
(guilin: City {name:"guilin"} ),
(kunming: City {name:"kunming"} ),
(chengdu: City {name:"chengdu"} ),
(xizang: City {name:"xizang"} ),
(beijing)-[:KNOWS]->(qingdao),
(shanghai)-[:KNOWS]->(guangzhou),
(guangzhou)-[:KNOWS]->(xiamen),
(shanghai)-[:KNOWS]->(zhengzhou),
(zhengzhou)-[:KNOWS]->(qingdao),
(beijing)-[:KNOWS]->(xian),
(xining)-[:KNOWS]->(xian),
(xian)-[:KNOWS]->(chengdu),
(chengdu)-[:KNOWS]->(xizang),
(zhengzhou)-[:KNOWS]->(kunming),
(guangzhou)-[:KNOWS]->(zhuhai),
(zhuhai)-[:KNOWS]->(guilin),
(beijing)-[:KNOWS]->(guangzhou)
  • You will got below cities graph

    graph

  1. Install python driver (http://neo4j.com/docs/api/python-driver/current/)
pip install neo4j-driver
  1. Just run Python script:query_city_graph.py. Then you will got all cities where Shanghai KNOWS within 2 hops and corresponding paths. Output is like below:
guangzhou
	shanghai -> guangzhou
beijing
	shanghai -> guangzhou
	beijing -> guangzhou
xiamen
	shanghai -> guangzhou
	guangzhou -> xiamen
zhuhai
	shanghai -> guangzhou
	guangzhou -> zhuhai
zhengzhou
	shanghai -> zhengzhou
qingdao
	shanghai -> zhengzhou
	zhengzhou -> qingdao
kunming
	shanghai -> zhengzhou
	zhengzhou -> kunming

neo4j-demo's People

Contributors

jicahoo avatar

Watchers

 avatar  avatar

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.