Skip to content

feat: add k-core #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2021
Merged

feat: add k-core #39

merged 1 commit into from
Dec 8, 2021

Conversation

xdddst
Copy link
Member

@xdddst xdddst commented Dec 7, 2021

feat: add k-core

*/
const kCore = (
graphData: GraphData,
K: number = 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

命名都小驼峰哈

const relativeEdges = edges.filter(edge => edge.source === minIndexId || edge.target === minIndexId);
relativeEdges.forEach(relativeEdge => {
const edgeIndex = edges.findIndex(edge => edge.id === relativeEdge.id);
edges.splice(edgeIndex, 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

剩下的 edges 好像就是 relativeEdges 的补集?那为啥不是直接 edges = edges.filter(edge => !(edge => edge.source === minIndexId || edge.target === minIndexId))

feat: add k-core

chore: perf code

chore: perf code

chore: perf code
@Yanyan-Wang Yanyan-Wang merged commit 0f6188b into master Dec 8, 2021
@Yanyan-Wang Yanyan-Wang deleted the feat/k-core branch December 8, 2021 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants