当前位置: 首页 > article >正文

pycharm链接neo4j数据库(简单)

1.安装pycharm

2.安装库

 pip install py2neo -i https://pypi.tuna.tsinghua.edu.cn/simple  
 

3.代码试运行 

from py2neo import Graph, Node, Relationship

# 连接到Neo4j数据库,使用Bolt协议
graph = Graph("bolt://localhost:7687", auth=("neo4j", "password"))

# 创建根节点
greedy_algorithm = Node("GreedyAlgorithm", name="Greedy Algorithm")

# 创建贪心算法的基本概念节点
basic_concept = Node("BasicConcept", name="基本概念")
graph.create(greedy_algorithm)
graph.create(basic_concept)

# 创建贪心算法的特点节点
features = Node("Features", name="特点")
graph.create(features)

# 创建贪心算法适用场景节点
app_scenario = Node("AppScenario", name="适用场景")
graph.create(app_scenario)

# 创建贪心算法示例节点
examples = Node("Examples", name="算法示例")
graph.create(examples)

# 创建贪心算法在优化问题中的应用节点
optimization = Node("Optimization", name="优化问题")
graph.create(optimization)

# 创建与其他算法的比较节点
comparison = Node("Comparison", name="与其他算法的比较")
graph.create(comparison)

# 创建局限性节点
limitations = Node("Limitations", name="局限性")
graph.create(limitations)

# 创建关系
graph.create(Relationship(greedy_algorithm, "INCLUDES", basic_concept))
graph.create(Relationship(greedy_algorithm, "INCLUDES", features))
graph.create(Relationship(greedy_algorithm, "INCLUDES", app_scenario))
graph.create(Relationship(greedy_algorithm, "INCLUDES", examples))
graph.create(Relationship(greedy_algorithm, "INCLUDES", optimization))
graph.create(Relationship(greedy_algorithm, "INCLUDES", comparison))
graph.create(Relationship(greedy_algorithm, "INCLUDES", limitations))

# 查询并打印结果
results = graph.run("MATCH (a:GreedyAlgorithm)-[r]->(b) RETURN a, r, b")
for record in results:
    print(record)

4.打开浏览器中的neo4j 


http://www.kler.cn/a/416695.html

相关文章:

  • 02.10 TCP之文件传输
  • ‌双非硕士的抉择:自学嵌入式硬件开发还是深入Linux C/C++走软开?
  • FPGA 28 ,基于 Vivado Verilog 的呼吸灯效果设计与实现( 使用 Vivado Verilog 实现呼吸灯效果 )
  • Leetcode - 周赛435
  • 结构形模式---桥接模式
  • 1、http介绍
  • 系统思考—结构影响行为
  • ubuntu24.04 python环境
  • jdk8没有InputStream.transferTo()
  • 鸿蒙千帆启新程,共绘数字生态蓝图
  • 腾讯阅文集团Android面试题及参考答案
  • 【查询目录】.NET开源 ORM 框架 SqlSugar 系列
  • 在VMware虚拟机上安装Kali Linux的详细教程(保姆级教程)
  • 腾讯微众银行大数据面试题(包含数据分析/挖掘方向)面试题及参考答案
  • 鸿蒙NEXT元服务:利用App Linking实现无缝跳转与二维码拉起
  • Linux系统编程——进程替换
  • Python异步编程新写法:asyncio模块的最新实践
  • K8s的API资源对象NetworkPolicy
  • BiGRU:双向门控循环单元在序列处理中的深度探索
  • SAP Native SQL 的简单说明
  • C#里怎么样LINQ来从数组里获得大于某数的值?
  • GPT诞生两周年,AIPC为连接器带来什么新变化?
  • vue3 ts button 组件封装
  • Docker 清理镜像策略详解
  • Vue3组件通信的8种方式,完整源码带注释
  • 图解:XSS攻击原理与安全过滤