from py2neo import Graph, Node, Relationship
gragh = Graph('http://localhost:7474', auth = ('neo4j', '123456'))
gragh.delete_all()
test_node_1 = Node("Comunity",name="腾讯")
test_node_2 = Node("Comunity",name="网易")
test_node_3 = Node("Comunity",name="华为")
test_node_4 = Node("Comunity",name="微软")
test_node_5 = Node("Comunity",name="谷歌")
test_node_6 = Node("Comunity",name="苹果")
gragh.create(test_node_1)
gragh.create(test_node_2)
gragh.create(test_node_3)
gragh.create(test_node_4)
gragh.create(test_node_5)
gragh.create(test_node_6)
title_node_1 = Node("title",name="互联网公司")
gragh.create(title_node_1)
games_node_1 = Node("games",name="王者荣耀")
games_node_2 = Node("games",name="和平精英")
games_node_3 = Node("games",name="决战!平安原")
games_node_4 = Node("games",name="阴阳师")
gragh.create(games_node_1)
gragh.create(games_node_2)
gragh.create(games_node_3)
gragh.create(games_node_4)
lei_node_1 = Node("lei",name="中国企业")
lei_node_2 = Node("lei",name="国外企业")
gragh.create(lei_node_1)
gragh.create(lei_node_2)
title_1_call_lei_1 = Relationship(title_node_1,"拥有企业",lei_node_1)
title_1_call_lei_2 = Relationship(title_node_1,"拥有企业",lei_node_2)
gragh.create(title_1_call_lei_1)
gragh.create(title_1_call_lei_2)
lei_1_call_test_1 = Relationship(lei_node_1,"隶属企业",test_node_1)
lei_1_call_test_2 = Relationship(lei_node_1,"隶属企业",test_node_2)
lei_1_call_test_3 = Relationship(lei_node_1,"隶属企业",test_node_3)
lei_2_call_test_4 = Relationship(lei_node_2,"隶属企业",test_node_4)
lei_2_call_test_5 = Relationship(lei_node_2,"隶属企业",test_node_5)
lei_2_call_test_6 = Relationship(lei_node_2,"隶属企业",test_node_6)
gragh.create(lei_1_call_test_1)
gragh.create(lei_1_call_test_2)
gragh.create(lei_1_call_test_3)
gragh.create(lei_2_call_test_4)
gragh.create(lei_2_call_test_5)
gragh.create(lei_2_call_test_6)
test_1_call_games_1 = Relationship(test_node_1,"拥有游戏",games_node_1)
test_1_call_games_2 = Relationship(test_node_1,"拥有游戏",games_node_2)
test_2_call_games_3 = Relationship(test_node_2,"拥有游戏",games_node_3)
test_2_call_games_4 = Relationship(test_node_2,"拥有游戏",games_node_4)
gragh.create(test_1_call_games_1)
gragh.create(test_1_call_games_2)
gragh.create(test_2_call_games_3)
gragh.create(test_2_call_games_4)
games_1_call_games_3 = Relationship(games_node_1,"竞争关系",games_node_3)
games_3_call_games_1 = Relationship(games_node_3,"竞争关系",games_node_1)
gragh.create(games_1_call_games_3)
gragh.create(games_3_call_games_1)
System_node_1 = Node("System",name="操作系统")
gragh.create(System_node_1)
test_3_call_System_1 = Relationship(test_node_3,"拥有操作系统",System_node_1)
gragh.create(test_3_call_System_1)
test_4_call_System_1 = Relationship(test_node_4,"拥有操作系统",System_node_1)
gragh.create(test_4_call_System_1)
test_5_call_System_1 = Relationship(test_node_5,"拥有操作系统",System_node_1)
gragh.create(test_5_call_System_1)
test_6_call_System_1 = Relationship(test_node_6,"拥有操作系统",System_node_1)
gragh.create(test_6_call_System_1)
gragh.delete(games_node_1 )