pseudocode - set S = N \ {P} 在伪代码中意味着什么?
问题描述
从Wikipedia了解 DBscan 。文章有如下伪代码:
DBSCAN(DB, distFunc, eps, minPts) {
C = 0 /* Cluster counter */
for each point P in database DB {
if label(P) ≠ undefined then continue /* Previously processed in inner loop */
Neighbors N = RangeQuery(DB, distFunc, P, eps) /* Find neighbors */
if |N| < minPts then { /* Density check */
label(P) = Noise /* Label as Noise */
continue
}
C = C + 1 /* next cluster label */
label(P) = C /* Label initial point */
Seed set S = N \ {P} /* Neighbors to expand */
for each point Q in S { /* Process every seed point */
if label(Q) = Noise then label(Q) = C /* Change Noise to border point */
if label(Q) ≠ undefined then continue /* Previously processed */
label(Q) = C /* Label neighbor */
Neighbors N = RangeQuery(DB, distFunc, Q, eps) /* Find neighbors */
if |N| ≥ minPts then { /* Density check */
S = S ∪ N /* Add new neighbors to seed set */
}
}
}
}
我很确定|N| 将意味着 N 的计数。
这条线会是什么:
Seed set S = N \ {P} /* Neighbors to expand */
意思是?我认为S 是一个种子集,就像一个对象列表。N \ {P} 是什么意思?
解决方案
\
是补运算,因此是没有点N \ {P}
的邻居集合。表示围绕一定距离的所有点,由(查询结果包括)返回。N
P
P
RangeQuery(DB, distFunc, P, eps)
P
推荐阅读
- sql - 使用 CHARINDEX 传递给 RIGHT 函数的长度参数无效
- python - 在尊重日期时间的同时计算滚动分组的乘积
- c++ - 回文字符串问题:为什么我必须放 +1 而不是 -1 才能使这段代码工作?
- java - java - 如何按“/”分割并存储为像java中的树一样分层?
- php - 如何在php中放置php
- php - PHP 变量未填充到表单上的 HTML datetime-local 字段中
- bash - 如何让 Bash 脚本引用本地文件
- xslt - 使用节点和属性上的 group by 从 xml 到 xml 的 xslt 转换
- android - LiveData 和 MVVM 模式
- reactjs - 在 Firestore 和 Firebase Auth 中处理用户数据的最佳方式配置为允许每封电子邮件有多个帐户