Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3a1d21a commit d6cd367Copy full SHA for d6cd367
1 file changed
Graphs/Density.js
@@ -0,0 +1,11 @@
1
+/*
2
+The density of a network is a measure of how many edges exist proportional to
3
+how many edges would exist in a complete network (where all possible edges).
4
+https://networkx.org/documentation/networkx-1.9/reference/generated/networkx.classes.function.density.html
5
+*/
6
+function density (numberOfNodes, numberOfEdges, isDirected = false) {
7
+ const multi = isDirected ? 1 : 2
8
+ return (multi * numberOfEdges) / (numberOfNodes * (numberOfNodes - 1))
9
+}
10
+
11
+(() => { console.log(density(10, 2)) })()
0 commit comments