当前位置:网站首页>Figure data * reconstruction subgraph
Figure data * reconstruction subgraph
2022-06-13 03:19:00 【Tnoy. Ma】
Figure data * Reconstruct subgraph
Here’s the table of contents:
Figure data * Reconstruct subgraph
Subgraph reconstruction
It usually occurs in the data operation and maintenance stage . When the data is wrong or the data model is adjusted, you need toModifying data
when , The graph data nodes or relationships need to be reconstructed in batch . The method of data reconstruction avoids the reorganization and import of data , Save resources and carry out rapid batch operation at the same time .
Here is an introduction toNode mode
Subgraph reconstruction method under , This method is to merge nodes and migrate their association relationship at the same time . You need to specify the merged target node , And the merged target nodes , And specify the merge operation mode of its attributes in an optional mode .
One 、 Find the concepts that need to be merged
First , Find two target nodes that need to be merged , I'm going to use it here
Polyolefin materials
、Crystalline silicon furnace
, Two keyword nodes ( What is established here is the inclusion relation graph between keywords and documents , A word may appear in many different documents ).
MATCH (kw: key word ) WHERE kw.name IN [' Polyolefin materials ',' Crystalline silicon furnace '] RETURN kw
Two 、 Expand the concept to view one-time relationships
below
Brown
Represents a document ,Red
Indicates the keyword . The following query can be used to correlatePolyolefin materials
、Crystalline silicon furnace
The two keywords all once contain relation .
MATCH p=(kw: key word )--() WHERE kw.name IN [' Polyolefin materials ',' Crystalline silicon furnace '] RETURN p
3、 ... and 、 Create a new node
In the future
Polyolefin materials
andCrystalline silicon furnace
Two keyword nodes , And their one degree networks are merged into this new node .
CREATE (kw: Concept {name:' Industrial manufacturing '}) RETURN ID(kw) AS idN
Four 、 Merge the node list into the first node
4.1 Nodes to be operated
This query shows , Three nodes to be operated , among
green
For the new node just created , Its label isConcept
.
MATCH (n) WHERE ID(n) IN [2133617,34934,213289] RETURN n
4.2 Extend all the node relationships
Concept
The node currently has no association , In the next operation, I will put the aboveKeyword subgraph
Merge intoOn the concept node
.
4.3 Perform refactoring analysis
Such as
Nodes to be operated
in ,ID The first node in the list is a new nodeIndustrial manufacturing
Concept node , Other nodes after the first node and their associated relationships will be merged into the first node . The merged nodes , It will be deleted after execution .
Three options are supported for attribute operation during merging :overwrite、discard、combine.
overwrite
Will override the attributes of the merged entity ;discard
No action will be performed when the attribute is repeated ;combine
When the attribute is repeated , Will be stored in an array .
When the relationship between the merged node and the merged node is duplicate, a new node will be created , have access to
apoc.refactor.mergeRelationships
Then merge the relationship ;apoc.refactor.mergeRelationships
When merging relationships, you need to pay attention to , The start and end nodes of the relationship must be the same , Configurable properties andapoc.refactor.mergeNodes
It's the same .
4.4 Set not to operate on node attributes during refactoring
The default operation : If the relationship on the node is repeated , Will the new , That is, the edges may repeat ; The labels of the nodes are merged into the first node .
MATCH (n) WHERE ID(n) IN [2133617,34934,213289] WITH COLLECT(n) AS nodes
CALL apoc.refactor.mergeNodes(nodes,{properties:'discard'}) YIELD node RETURN node
4.5 The effect of reconstruction
Three nodes become one node , Three subgraphs become one subgraph .
Four 、 summary
This paper introduces , Data reconstruction method in node mode . It is very practical in the actual data production operation , Refactoring in relational mode is similar to this approach . During refactoring, data is generally operated in batches , In support of ACID In order to avoid the frequent occurrence of life and death lock problems in the database , Concurrent operation of data is not supported in stored procedures .
边栏推荐
- Stack: daily temperature
- Rustup installation
- Hash table: valid anagrams
- On the career crisis of programmers at the age of 35
- Array in PHP array function_ Slice and array_ flip
- Implode and explode in golang
- Common command records of redis client
- 【pytorch 记录】pytorch的变量parameter、buffer。self.register_buffer()、self.register_parameter()
- C method parameter: out
- Flutter reports an error type 'Int' is not a subtype of type 'string' wonderful experience
猜你喜欢
Binary tree initialization code
Wechat applet switch style rewriting
C # simple understanding - method overloading and rewriting
2-year experience summary to tell you how to do a good job in project management
English语法_方式副词-位置
技术博客,经验分享宝典
开源-校园论坛和资源共享小程序
Vs Code modify default terminal_ Modify the default terminal opened by vs Code
C simple understanding - generics
Installing the IK word breaker
随机推荐
English语法_频率副词
Techniques for collecting stringgrid
C language function strcmp() (compare two strings)
MMAP usage in golang
The use of curl in PHP
视频播放屡破1000W+,在快手如何利用二次元打造爆款
2019 - sorting out the latest and most comprehensive IOS test questions (including framework and algorithm questions)
C method parameter: out
This article takes you to learn DDD, basic introduction
Age anxiety? How to view the 35 year old programmer career crisis?
产品需求文档如何编写
2022 qianle micro cloud technology learning task plan
2022.05.29
【 enregistrement pytorch】 paramètre et tampon des variables pytorch. Self. Register Buffer (), self. Register Paramètre ()
2-year experience summary to tell you how to do a good job in project management
Introduction to Sitemap_ Sitemap online generation and sorting
Explode and implode in PHP
JS merge multiple string arrays to maintain the original order and remove duplicates
Spark Foundation
[JVM Series 5] performance testing tool