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.
2 parents c10cb8c + 493aab4 commit 3bc5798Copy full SHA for 3bc5798
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