You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The connectSome looks like it makes num connections between the nodes in gss. It will not connect nodes to themselves but it doesn't seem to prevent connecting A to B and then B to A and calling that two connections.
Sometimes the tests demand a certain number of connections for each node after using connectSome but there does not appear to be any guarantee this will actually happen due to the above, which may be one reason why the more complicated tests in this module can be a bit flaky.
The text was updated successfully, but these errors were encountered:
Actually it's kind of worse because i doesn't get incremented while j < num is true, so the node for i = 0 gets loads of connections but high i values might not get any, so it can cause disjoint networks to be formed.
A better algorithm might be:
Decrement num after any connection is created, return when num === 0
Reject any num value that is less than gss.length
Maintain a collection of connected nodes
Connect two nodes from gss and add them to the connected nodes collection
Until all nodes have one connection, connect them to a random node in the connected nodes collection and then store them in the connected nodes collection
Until num === 0 connect two random nodes from the connected nodes collection that are not the same node and are not already connected
Ah, no - forget it. It's supposed to ensure every member of gss has num peers, not num connections between gss members.
There is a bug in there though, if it generates the same value of n twice it treats it as two separate connections, so there's no guarantee each member of gss will have num connections which can cause promises like these to never resolve.
The connectSome looks like it makes
num
connections between the nodes ingss
. It will not connect nodes to themselves but it doesn't seem to prevent connectingA
toB
and thenB
toA
and calling that two connections.Sometimes the tests demand a certain number of connections for each node after using
connectSome
but there does not appear to be any guarantee this will actually happen due to the above, which may be one reason why the more complicated tests in this module can be a bit flaky.The text was updated successfully, but these errors were encountered: