Merged
Conversation
Author
Yanyan-Wang
reviewed
Oct 8, 2023
packages/graph/src/utils.ts
Outdated
| let distance = 0; | ||
| switch (distanceType) { | ||
| case DistanceType.EuclideanDistance: | ||
| distance = new Vector(item).euclideanDistance(new Vector(otherItem)); |
Contributor
There was a problem hiding this comment.
感觉 new 两个 vector 有点浪费性能,还不如直接数值计算一下
packages/graph/src/k-means.ts
Outdated
| // When the number of nodes or the length of the attribute set is less than k, k will be adjusted to the smallest of them | ||
| const finalK = Math.min(k, nodes.length, allPropertiesWeightUniq.length); | ||
| for (let i = 0; i < nodes.length; i++) { | ||
| nodes[i].data.originIndex = i; |
Contributor
There was a problem hiding this comment.
现在做了数据隔离,这种写到数据里面的方式不太好了,是不是可以另外存到一个 map 里面
packages/graph/src/k-means.ts
Outdated
| id: `${i}`, | ||
| nodes: [nodes[maxDistanceNodeIndex]] | ||
| }; | ||
| nodes[maxDistanceNodeIndex].data.clusterId = String(i); |
Contributor
There was a problem hiding this comment.
同上,可以用一个 Map<ID, string> 存储这些信息,key 是节点 id, value 是聚类 id
Contributor
|
感谢 PR ~ |
…nd return it from k-means func
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
propertiesKeyis a param to detect whether the relevant property used in k-means is in nodes.dataproperty collects all of the properties of nodes,propertiesKeyparam have been removed in v5 algorithm.