Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Graph 通过在简化图中查找模式计算ARI_Graph_Neo4j_Cypher_Cluster Analysis_Partitioning - Fatal编程技术网

Graph 通过在简化图中查找模式计算ARI

Graph 通过在简化图中查找模式计算ARI,graph,neo4j,cypher,cluster-analysis,partitioning,Graph,Neo4j,Cypher,Cluster Analysis,Partitioning,我有一个图,其中项目可以进行不同的分区,即项目的集群在两个分区之间有所不同。我想计算两个不同分区之间的差异,以评估它们之间的差异 图表 这是图表的一般结构: (:Store)-[:SELLS]->(:Product)-[:SIMILAR]-(:Product)<-[:SELLS]-(:Store) --- red_beans ------ orange_beans --- /

我有一个图,其中项目可以进行不同的分区,即项目的集群在两个分区之间有所不同。我想计算两个不同分区之间的差异,以评估它们之间的差异

图表 这是图表的一般结构:

(:Store)-[:SELLS]->(:Product)-[:SIMILAR]-(:Product)<-[:SELLS]-(:Store)


              --- red_beans     ------  orange_beans  ---
             /                     /                      \
supermart ------  yellow_beans  ---                        --- ecomart
             \                     \                      /
              --- blue_beans    ------  green_beans   ---




                                    ---  blue_jello   ---
                                   /                      \
supermart   ---   purple_jello  ---                        --- ecomart
                                   \                      /
                                    ---  red_jello    ---
(a:Store)-[:SELLS]->(:Product)-[:SIMILAR]-(:Product)<-[:SELLS]-(b:Store)
                         |                     |
                    [:BUNDLED]            [:BUNDLED]
                         |                     |
(a:Store)-[:SELLS]->(:Product)-[:SIMILAR]-(:Product)<-[:SELLS]-(b:Store)

问题 无论产品颜色如何(一种产品的不同颜色被认为是同一种产品),对于两家商店都提供的产品(类似的产品实际上是两家商店都提供的同一种产品),不同商店的捆绑包有多大差异


过程 第一步是缩小图表以对应问题。它(实际上)应该是这样的:

这应该是产品减少的自然延伸。多条边也将减少为一条


第二步是提取计算不同产品分区之间的ARI所需的信息。ARI是:

计算它需要三个度量:


在两家商店的捆绑包中找到的产品对数。基本上,此模式出现在图表中的次数:

(:Store)-[:SELLS]->(:Product)-[:SIMILAR]-(:Product)<-[:SELLS]-(:Store)


              --- red_beans     ------  orange_beans  ---
             /                     /                      \
supermart ------  yellow_beans  ---                        --- ecomart
             \                     \                      /
              --- blue_beans    ------  green_beans   ---




                                    ---  blue_jello   ---
                                   /                      \
supermart   ---   purple_jello  ---                        --- ecomart
                                   \                      /
                                    ---  red_jello    ---
(a:Store)-[:SELLS]->(:Product)-[:SIMILAR]-(:Product)<-[:SELLS]-(b:Store)
                         |                     |
                    [:BUNDLED]            [:BUNDLED]
                         |                     |
(a:Store)-[:SELLS]->(:Product)-[:SIMILAR]-(:Product)<-[:SELLS]-(b:Store)

一个商店中可能的产品对数。由于我们只考虑在两个商店都可用的产品,每个商店都有相同数量的产品,这将是:

MATCH (a:Store)-[:SELLS]->(p:Product)
RETURN a, count(p)*(count(p)-1)/2

实施 在cypher查询中实现这一点并不像我预期的那样自然。我在翻译我的过程中遇到了困难,尤其是第一步,如果有任何帮助,我将不胜感激

编辑:这是我正在处理的图形:

with [
  {
    store: 'supermart',
    products: ['red_beans','yellow_beans','blue_beans','purple_jello',
    'orange_icecream','pink_icecream','blue_candy','brown_cake']
  },
  {
    store: 'ecomart',
    products: ['orange_beans','green_beans','blue_jello','red_jello',
    'red_icecream','white_icecream','purple_candy','white_sugar']
  }
] as sells
unwind sells as sell
merge (s:Store {name: sell.store})
with s, sell
unwind sell.products as product
merge (p:Product {name: product})
merge (s)-[:SELLS]->(p);

with [
 ['red_beans', 'purple_jello'],
 ['red_beans', 'blue_beans'],
 ['blue_beans', 'purple_jello'],
 ['yellow_beans', 'brown_cake'],
 ['orange_icecream', 'pink_icecream'],
 ['pink_icecream', 'blue_candy'],
 ['orange_beans', 'red_jello']
] as bundles
unwind bundles as bundle
match (p1:Product {name: bundle[0]})
match (p2:Product {name: bundle[1]})
merge (p1)-[:BUNDLED]-(p2);

with [
  ['red_beans', 'orange_beans'],
  ['yellow_beans', 'orange_beans'],
  ['yellow_beans', 'green_beans'],
  ['blue_beans', 'green_beans'],
  ['purple_jello', 'blue_jello'],
  ['purple_jello', 'red_jello'],
  ['orange_icecream', 'red_icecream'],
  ['pink_icecream', 'red_icecream'],
  ['pink_icecream', 'white_icecream'],
  ['blue_candy', 'purple_candy']
] as similarities
unwind similarities as similar
match (p1:Product {name: similar[0]})
match (p2:Product {name: similar[1]})
merge (p1)-[:SIMILAR]-(p2);


此图的ARI为0.571428

如何在latex中编写ARI公式?
(a:Store)-[:SELLS]->(:Product)
                         |
                    [:BUNDLED]
                         |
(a:Store)-[:SELLS]->(:Product)
MATCH (a:Store)-[:SELLS]->(p:Product)
RETURN a, count(p)*(count(p)-1)/2
with [
  {
    store: 'supermart',
    products: ['red_beans','yellow_beans','blue_beans','purple_jello',
    'orange_icecream','pink_icecream','blue_candy','brown_cake']
  },
  {
    store: 'ecomart',
    products: ['orange_beans','green_beans','blue_jello','red_jello',
    'red_icecream','white_icecream','purple_candy','white_sugar']
  }
] as sells
unwind sells as sell
merge (s:Store {name: sell.store})
with s, sell
unwind sell.products as product
merge (p:Product {name: product})
merge (s)-[:SELLS]->(p);

with [
 ['red_beans', 'purple_jello'],
 ['red_beans', 'blue_beans'],
 ['blue_beans', 'purple_jello'],
 ['yellow_beans', 'brown_cake'],
 ['orange_icecream', 'pink_icecream'],
 ['pink_icecream', 'blue_candy'],
 ['orange_beans', 'red_jello']
] as bundles
unwind bundles as bundle
match (p1:Product {name: bundle[0]})
match (p2:Product {name: bundle[1]})
merge (p1)-[:BUNDLED]-(p2);

with [
  ['red_beans', 'orange_beans'],
  ['yellow_beans', 'orange_beans'],
  ['yellow_beans', 'green_beans'],
  ['blue_beans', 'green_beans'],
  ['purple_jello', 'blue_jello'],
  ['purple_jello', 'red_jello'],
  ['orange_icecream', 'red_icecream'],
  ['pink_icecream', 'red_icecream'],
  ['pink_icecream', 'white_icecream'],
  ['blue_candy', 'purple_candy']
] as similarities
unwind similarities as similar
match (p1:Product {name: similar[0]})
match (p2:Product {name: similar[1]})
merge (p1)-[:SIMILAR]-(p2);