The edge list mutator methods insertEdge and removeEdge call Array.splice. It looks like the splice method takes Θ(n) time in popular JavaScript engines. (I'd be happy to be proven wrong, however.) As a result, the running times of link and cut() are at least linear in the total number of vertices. However, README.md states that updates take O(log2V) time, which is presumably the intention. It is possible to achieve this running time (at least, amortized with high probability) by storing the edges in linked lists rather than arrays, thereby avoiding the calls to splice. (You could even use binary search trees in place of sorted arrays if desired.)
The edge list mutator methods
insertEdge
andremoveEdge
callArray.splice
. It looks like thesplice
method takes Θ(n) time in popular JavaScript engines. (I'd be happy to be proven wrong, however.) As a result, the running times oflink
andcut()
are at least linear in the total number of vertices. However, README.md states that updates take O(log2V) time, which is presumably the intention. It is possible to achieve this running time (at least, amortized with high probability) by storing the edges in linked lists rather than arrays, thereby avoiding the calls tosplice
. (You could even use binary search trees in place of sorted arrays if desired.)