绑定完请刷新页面
取消
刷新

分享好友

×
取消 复制
Neo4j构建pyhton知识体系图谱___“贪心学院第二个主题项目代码”
2020-05-21 16:28:35

作业:利用Neo4j构建图片所示内容,熟悉Cypher查询语言

知识体系图谱如下图:

1.创建"知识"节点:

CREATE(:knowledge{name:"Python基础"}),(:knowledge{name:"Requests"}),(:knowledge{name:"bas4"}),(:knowledge{name:"Scrapy"}),
(:knowledge{name:"MySQL"}),(:knowledge{name:"文件处理"}),(:knowledge{name:"Flask"}),(:knowledge{name:"Django"}),
(:knowledge{name:"MongoDB"}),(:knowledge{name:"Hive"}),(:knowledge{name:"HBase"}),(:knowledge{name:"Scala"}),(:knowledge{name:"Spark"}),
(:knowledge{name:"Hadoop"}),(:knowledge{name:"JAVA"}),(:knowledge{name:"Flink"}),(:knowledge{name:"Storm"}),(:knowledge{name:"kafka"}),
(:knowledge{name:"flume"}),(:knowledge{name:"网络"}),(:knowledge{name:"Xpath"}),(:knowledge{name:"CSS"}),(:knowledge{name:"HTML"}),
(:knowledge{name:"Linux"}),(:knowledge{name:"Windows办公软件"}),(:knowledge{name:"所属行业的业务知识"}),(:knowledge{name:"统计"}),
(:knowledge{name:"高数"}),(:knowledge{name:"机器学习"}),(:knowledge{name:"深度学习"})

2.创建“岗位”节点

CREATE(:job{name:"自动化办公"}),(:job{name:"Web开发"}),(:job{name:"爬虫"}),(:job{name:"数据分析"}),(:job{name:"人工智能"}),
(:job{name:"大数据"})

3.创建“岗位方向”节点

CREATE(:direction{name:"离线计算"}),(:direction{name:"实时计算"}),(:direction{name:"视觉"}),(:direction{name:"语音"}),
(:direction{name:"NLP"}),(:direction{name:"推荐"})

4.创建节点间的关系

求教!! 这里添加关系的时候,用最初的写法写了很多句,需要一条一条的执行,很low,请教各位大神!请不吝赐教!

1.有没有办法把,这么多句,写成一条Cypher;

2.有没有更高级的方法?

create(n1:knowledge{name:"Python基础"}),(n2:knowledge{name:"Requests"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Requests"}),(n2:knowledge{name:"bas4"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"bas4"}),(n2:knowledge{name:"Scrapy"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Scrapy"}),(n2:knowledge{name:"MySQL"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Scrapy"}),(n2:knowledge{name:"MongoDB"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Python基础"}),(n2:knowledge{name:"文件处理"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"文件处理"}),(n2:knowledge{name:"Flask"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"文件处理"}),(n2:knowledge{name:"Django"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Flask"}),(n2:knowledge{name:"MySQL"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Django"}),(n2:knowledge{name:"MySQL"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Python基础"}),(n2:knowledge{name:"MySQL"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Python基础"}),(n2:knowledge{name:"MongoDB"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Python基础"}),(n2:knowledge{name:"Hive"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Python基础"}),(n2:knowledge{name:"HBase"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"自动化办公"}),(n2:knowledge{name:"Python基础"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"Web开发"}),(n2:knowledge{name:"Python基础"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"Web开发"}),(n2:knowledge{name:"Linux"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"数据分析"}),(n2:knowledge{name:"Python基础"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"人工智能"}),(n2:knowledge{name:"Python基础"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;

create(n1:job{name:"爬虫"}),(n2:knowledge{name:"网络"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"爬虫"}),(n2:knowledge{name:"HTML"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"爬虫"}),(n2:knowledge{name:"Linux"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"HTML"}),(n2:knowledge{name:"Xpath"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"HTML"}),(n2:knowledge{name:"CSS"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;

create(n1:job{name:"数据分析"}),(n2:knowledge{name:"Linux"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"数据分析"}),(n2:knowledge{name:"Windows办公软件"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"数据分析"}),(n2:knowledge{name:"所属行业的业务知识"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"数据分析"}),(n2:knowledge{name:"统计"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"统计"}),(n2:knowledge{name:"高数"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"统计"}),(n2:knowledge{name:"机器学习"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"人工智能"}),(n2:knowledge{name:"高数"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;

create(n1:knowledge{name:"机器学习"}),(n2:knowledge{name:"Linux"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"机器学习"}),(n2:knowledge{name:"深度学习"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"深度学习"}),(n2:direction{name:"视觉"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"深度学习"}),(n2:direction{name:"NLP"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"深度学习"}),(n2:direction{name:"语音"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"深度学习"}),(n2:direction{name:"推荐"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;

create(n1:job{name:"大数据"}),(n2:direction{name:"离线计算"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:job{name:"大数据"}),(n2:direction{name:"实时计算"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:direction{name:"离线计算"}),(n2:knowledge{name:"Hive"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:direction{name:"离线计算"}),(n2:knowledge{name:"HBase"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:direction{name:"离线计算"}),(n2:knowledge{name:"Scala"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:direction{name:"离线计算"}),(n2:knowledge{name:"Hadoop"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"Scala"}),(n2:knowledge{name:"Spark"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:direction{name:"实时计算"}),(n2:knowledge{name:"JAVA"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"JAVA"}),(n2:knowledge{name:"Hadoop"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"JAVA"}),(n2:knowledge{name:"Flink"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"JAVA"}),(n2:knowledge{name:"flume"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"JAVA"}),(n2:knowledge{name:"kafka"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;
create(n1:knowledge{name:"JAVA"}),(n2:knowledge{name:"Storm"})
create(n1)-[r:relationship]->(n2)
return n1,r,n2;

5.查询关系:MATCH p=()-[r:relationship]->() RETURN p LIMIT 60

分享好友

分享这个小栈给你的朋友们,一起进步吧。

Neo4j 图形数据库
创建时间:2020-05-19 17:48:05
Neo4j是一个高性能的,NOSQL图形数据库,它将结构化数据存储在网络上而不是表中。它是一个嵌入式的、基于磁盘的、具备完全的事务特性的Java持久化引擎,但是它将结构化数据存储在网络(从数学角度叫做图)上而不是表中。Neo4j也可以被看作是一个高性能的图引擎,该引擎具有成熟数据库的所有特性。程序员工作在一个面向对象的、灵活的网络结构下而不是严格、静态的表中——但是他们可以享受到具备完全的事务特性、企业级的数据库的所有好处。 Neo4j因其嵌入式、高性能、轻量级等优势,越来越受到关注.
展开
订阅须知

• 所有用户可根据关注领域订阅专区或所有专区

• 付费订阅:虚拟交易,一经交易不退款;若特殊情况,可3日内客服咨询

• 专区发布评论属默认订阅所评论专区(除付费小栈外)

技术专家

查看更多
  • ☀️
    专家
戳我,来吐槽~