2021-01-23 15:56:09 -03:00
|
|
|
/*
|
|
|
|
|
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
|
|
|
|
|
*/
|
|
|
|
|
function density (numberOfNodes, numberOfEdges, isDirected = false) {
|
|
|
|
|
const multi = isDirected ? 1 : 2
|
|
|
|
|
return (multi * numberOfEdges) / (numberOfNodes * (numberOfNodes - 1))
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-10 17:55:08 +02:00
|
|
|
export { density }
|