Giter Site home page Giter Site logo

knowledge_graph's Introduction

Knowledge_graph

Database version:

Neo4j 3.4.5

Query:

// Load data from csv db.csv with a single relationship

load csv with headers from "file:///db.csv" as csvoutline merge(word1:Word{name:csvoutline.source}) merge(word2:Word{name:csvoutline.destination}) merge (word1)-[:RELATED{weight:csvoutline.distance}]-(word2)

// load data with multople relationship and weight

load csv with headers from "file:///db.csv" as csvoutline merge(word1:Word{name:csvoutline.source}) merge(word2:Word{name:csvoutline.destination}) with word1, word2, csvoutline CALL apoc.create.relationship(word1, csvoutline.relationshipType,{weight:csvoutline.distance}, word2) yield rel Return count(word1)

// Query to match the words MATCH (n:Word)-[r]->(n2:Word) where n.name='fawn' RETURN n2,r.weight order by r.weight desc limit 5

// neighbor nodes and total distance to each query words match(n:Word)-[r]->(n1:Word)-[r2]->(n2:Word) where n1.name='pilot' AND n.name in ['captain','chair'] return n.name as source,n2.name as destination,sum(r.weight+r2.weight) as total order by destination,total

// Minumum Spanning Tree match (n:Word)-[r]->() where n.name in ['sofa','fawn'] call algo.spanningTree.minimum('Word','RELATED','weight',id(n),{write:true, writeProperty:"MINST"}) yield effectiveNodeCount return effectiveNodeCount;

// Read MST Relationship match path = (n:Word)-[:MINST]->() where n.name in ['sofa','fawn'] with relationships(path) as rels unwind rels as rel with distinct rel as rel Return startNode(rel).name as source, endNode(rel).name as destination, rel.weight as cost

// delete relationship MATCH p=()-[r:MINST]->() delete r

knowledge_graph's People

Contributors

concept-inversion avatar

Watchers

 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.