forked from TheAlgorithms/JavaScript
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDensity.js
More file actions
Latest commit
11 lines (10 loc) · 467 Bytes
/
Copy pathDensity.js
File metadata and controls
11 lines (10 loc) · 467 Bytes
1
2
3
4
5
6
7
8
9
10
11
/*
The density of a network is a measure of how many edges exist proportional to
how many edges would exist in a complete network (where all possible edges).
https://networkx.org/documentation/networkx-1.9/reference/generated/networkx.classes.function.density.html
*/
functiondensity(numberOfNodes,numberOfEdges,isDirected=false){
constmulti=isDirected ? 1 : 2
return(multi*numberOfEdges)/(numberOfNodes*(numberOfNodes-1))
}
export{density}