summaryrefslogtreecommitdiff
path: root/script/neo4jcommand.py
diff options
context:
space:
mode:
authorhandingkang <[email protected]>2024-01-15 19:54:42 +0800
committerhandingkang <[email protected]>2024-01-15 19:54:42 +0800
commit576b2ee0d35be920645ab5d93d29ae56a09b96ab (patch)
treee990c1c5e45131cc2a0cec35e4078ea6ec3ec9d2 /script/neo4jcommand.py
parentd397aaf0416e52c8a261b45eaf54bd29273b3eac (diff)
功能更新
Diffstat (limited to 'script/neo4jcommand.py')
-rw-r--r--script/neo4jcommand.py72
1 files changed, 72 insertions, 0 deletions
diff --git a/script/neo4jcommand.py b/script/neo4jcommand.py
new file mode 100644
index 0000000..022aa5d
--- /dev/null
+++ b/script/neo4jcommand.py
@@ -0,0 +1,72 @@
+# 去重指令
+distinct = '''
+match (n:NodeResolver53)
+WITH n ORDER BY n.W DESC
+with n.IP as IP,collect(n) as nodes,count(*) as c
+where c>1
+CALL apoc.refactor.mergeNodes(nodes,
+{properties:'discard',mergeRels:true})
+YIELD node
+RETURN count(*)
+'''
+
+# 新建catelog
+gds_newgraph = '''
+CALL gds.graph.project(
+ 'myGraph',
+ 'NodeResolver53',
+ 'IP_LINK',
+ {
+ relationshipProperties: 'W'
+ }
+)
+'''
+
+# 删除旧的catelog
+gds_delgraph = '''
+CALL gds.graph.drop('myGraph', false) YIELD graphName
+'''
+
+# 高风险节点
+dangerous_nodes = '''
+CALL gds.pageRank.stream('myGraph')
+YIELD nodeId, score
+with gds.util.asNode(nodeId) as n
+WHERE n.IPType contains "6"
+RETURN n.IP as ip, n.ISP as isp,n.CCODE as ccode,n.COU as cou,n.PROV as prov, score
+ORDER BY score DESC, ip ASC,isp ASC,ccode ASC,cou ASC,prov ASC limit 30'''
+
+# 双栈服务数量统计
+dualcountcypher = '''
+ CALL gds.wcc.stream('myGraph')
+ YIELD nodeId,componentId
+ with componentId as cid,count(*) as c
+ where 1<c<5
+ with collect(cid) as cc
+ CALL gds.wcc.stream('myGraph')
+ YIELD nodeId,componentId
+ where componentId in cc
+ with gds.util.asNode(nodeId).IP as ip,componentId
+ where ip contains ":"
+ return count(distinct componentId)
+ '''
+# 双栈服务详细数据
+dualdatacypher = '''
+ CALL gds.wcc.stream('myGraph')
+ YIELD nodeId,componentId
+ with componentId as cid,count(*) as c
+ where 1<c<5
+ with collect(cid) as cc
+ CALL gds.wcc.stream('myGraph')
+ YIELD nodeId,componentId
+ where componentId in cc
+ with gds.util.asNode(nodeId).IP as ip,componentId
+ where ip contains ":"
+ with collect(componentId) as ccl
+ CALL gds.wcc.stream('myGraph')
+ YIELD nodeId,componentId
+ where componentId in ccl
+ with gds.util.asNode(nodeId) as n,componentId
+ return n.IP,n.ISP,n.COU,n.CCODE,n.PROV,n.LAT,n.LNG,componentId
+ order by componentId
+ '''