GraphGists

使用 Neo4j 和 Cypher 进行多维图度量

此 Gist 的目标是演示我们在论文 Towards the characterization of realistic models: evaluation of multidisciplinary graph metrics 中收集的图度量。

数据集

例如,我们使用了一个简单的铁路网络,包括两条路线、三个路段、一个开关和三个传感器

railway 1
图 1. 铁路网络

此示例作为图的可能图形表示如下

railway 2
图 2. 铁路图

短视频 演示了如何将铁路网络转换为图。

以下查询创建图(加载页面时会自动执行查询)。

接下来,我们将介绍度量的正式定义,并使用 Cypher 查询在示例图上对其进行评估。有关符号的详细信息,请参阅 论文

一维度量

聚类系数

\(C(v) = \frac {\big| a, b \mid \mathit{Connected}(v, a) \land \mathit{Connected}(v, b) \land \mathit{Connected}(a, b) \big|} {\big| a, b \mid \mathit{Connected}(v, a) \land \mathit{Connected}(v, b) \big|}\)

多维度量

在维度-节点对上解释的度量

维度度

\(\mathit{Degree}\left(v,d\right) = \left|\big\{ w \in V \mid \mathit{Connected}(v, w, d) \big\}\right|\)

在维度上解释的度量

节点维度活动

\( \mathit{NDA}(d) = \big| \{ v \in V \mid \mathit{Active}(v,d) \} \big| \)

节点维度连接性

\( \mathit{NDC}(d) = \frac{\mathit{NDA}(d)}{|V|} \)

边维度活动

\( \mathit{EDA}(d) = \big| \{ (v,w,d) \in E \mid v,w \in V \} \big| \)

边维度连接性

\( \mathit{EDC}(d) = \frac{\mathit{EDA}(d)}{|E|} \)

在节点上解释的度量

节点活动

\( \mathit{NA}(v) = \big| \{ d \in D \mid \mathit{Active}(v, d) \} \big| \)

多路复用参与系数

\( \mathit{MPC}(v) = \frac{|D|}{|D| - 1} \left[ 1 - \sum\limits_{d\in D}^{}{\left(\frac{\mathit{Degree}(v,d)}{\mathit{Degree}(v,D)}\right)^2} \right] \)
维度聚类系数

DC1 变体

\( \mathit{DC}_1(v) = \frac {\big| a, b \mid \mathit{Connected}(v, a, d_1) \land \mathit{Connected}(v, b, d_1) \land \mathit{Connected}(a, b, d_2) \land d_1 \neq d_2 \big|} {\big| a, b \mid \mathit{Connected}(v, a, d_1) \land \mathit{Connected}(v, b, d_1) \big|} \)

DC2 变体

\( \mathit{DC}_2(v) = \frac {\big| a, b \mid \mathit{Connected}(v, a, d_1) \land \mathit{Connected}(v, b, d_2) \land \mathit{Connected}(a, b, d_3) \land d_1 \neq d_2 \land d_2 \neq d_3 \land d_1 \neq d_3 \big|} {\big| a, b \mid \mathit{Connected}(v, a, d_1) \land \mathit{Connected}(v, b, d_2) \land d_1 \neq d_2 \big|)} \)

在维度对上解释的度量

每个节点v节点活动二进制向量定义为

\( a_v = \left\{ a_v^{[1]},a_v^{[2]}, \dots, a_v^{[|D|]} \right\}, \text{where } a_v^{[d]} = \begin{cases} 1, & \text{if } \mathit{Active}(v,d),\\ 0, & \text{otherwise} \end{cases} \)

使用此向量,成对多路复用性度量为

\( Q(d_1, d_2) = \frac{1}{|V|} \sum_{v \in V} {a_v^{[d_1]} a_v^{[d_2]}} \)