jdfekete / reorder.js

JavaScript library to reorder matrices
BSD 3-Clause "New" or "Revised" License
126 stars 29 forks source link

Barycenter returns what? #33

Open deklanw opened 3 years ago

deklanw commented 3 years ago

I thought that the three values in the returned array are the permutations of the columns, the rows, and the number of crossings. But, I noticed in my results that the lengths of the permutations seem off.

Adding these two assertions to the tests in barycenter-test.js

  assert.isTrue(perms[0].length === mat[0].length)
  assert.isTrue(perms[1].length === mat.length)

causes a failure for the hard test, but not the simple test.

Am I missing something here? Thanks

nvbeusekom commented 2 years ago

I believe the issue here is that vertices that have no edges connected to them disappear from the ordering. They do show in the components, but they are omitted in the construction of the layers, because they have no neighbors:

const layer1 = comp.filter((n) => graph.outDegree(n) !== 0); const layer2 = comp.filter((n) => graph.inDegree(n) !== 0);