Skip to content

Commit

Permalink
fix(commDetection): 🐛 A node shouldn't update all it's neighbours in …
Browse files Browse the repository at this point in the history
…one go
  • Loading branch information
SkepticMystic committed Nov 4, 2021
1 parent 67b33ce commit c9fe8d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
6 changes: 2 additions & 4 deletions main.js

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions src/MyGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ export default class MyGraph extends Graph {
a: string,
options: { iterations: number }
): Promise<Communities> => {
console.log('running')
const labeledNodes: { [node: string]: number } = {}
this.nodes().forEach((node, i) => {
labeledNodes[node] = i
Expand All @@ -396,12 +395,11 @@ export default class MyGraph extends Graph {
const counts = getCounts(neighbourLabels)
const maxKey = getMaxKey(counts)

neighbours.forEach(
(neighbour) => (labeledNodes[neighbour] = Number.parseInt(maxKey))
)
labeledNodes[node] = Number.parseInt(maxKey)
}
})
}

const communities: Communities = {}
Object.entries(labeledNodes).forEach((labeledNode: [string, number]) => {
const [node, label] = labeledNode
Expand All @@ -411,7 +409,6 @@ export default class MyGraph extends Graph {
communities[label].push(node)
}
})
console.log('ended')
return communities
},

Expand Down

0 comments on commit c9fe8d9

Please sign in to comment.