Skip to content

Commit

Permalink
Changes to generate poster images
Browse files Browse the repository at this point in the history
  • Loading branch information
nvbeusekom committed Aug 29, 2022
1 parent f68d7ee commit a442807
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 5 deletions.
17 changes: 16 additions & 1 deletion examples/matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ function matrix(json) {

return nodes.map(function(n) { return n.spectral; });
}

function computeNN2OPT() {
var order = leafOrder(adjacency);

order.forEach(function(lo, i) {
nodes[i].leafOrder = lo;
});
return nodes.map(function(n) { return n.leafOrder; });
}

// Precompute the orders.
var orders = {
Expand All @@ -114,7 +123,8 @@ function matrix(json) {
leafOrderDist: computeLeaforderDist,
barycenter: computeBarycenter,
rcm: computeRCM,
spectral: computeSpectral
spectral: computeSpectral,
nn2opt: computeNN2OPT
};

// The default sort order.
Expand Down Expand Up @@ -240,6 +250,11 @@ function matrix(json) {
order("leafOrderDist");
//d3.select("#order").property("selectedIndex", 4);
}
else if (currentOrder == 'nn2opt') {
orders.nn2opt = computeNN2OPT;
order("nn2opt");
//d3.select("#order").property("selectedIndex", 4);
}

// leafOrder.forEach(function(lo, i) {
// nodes[lo].leafOrder = i;
Expand Down
1 change: 1 addition & 0 deletions examples/miserables/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ <h1><i>Les Misérables</i> Co-occurrence</h1>
<option value="barycenter">by Crossing Reduction</option>
<option value="rcm">by Bandwidth Reduction (RCM)</option>
<option value="spectral">Spectral</option>
<option value="nn2opt">NN-2OPT</option>
</select>

<p>Distance: <select id="distance">
Expand Down
2 changes: 1 addition & 1 deletion examples/timeseries/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<div style="margin-top:4px;margin-bottom: 4px">
<button type="button" onclick="random_permute(tables)">Random Order</button>
<button type="button" onclick="initial_order_permute(tables)">Initial Order</button>
<button type="button" onclick="max_mi_gx(tables)">NN-2OPT on Graph Gx</button>
<button type="button" onclick="nn_2opt_gx(tables)">NN-2OPT on Graph Gx</button>

</div>
<div style="margin-top:4px;margin-bottom: 4px">
Expand Down
4 changes: 2 additions & 2 deletions examples/timeseries/order_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function random_permute(t) {
computeQualities(t);
}

function max_mi_gx(t) {
function nn_2opt_gx(t) {
let timestep = getTimestep();
let start = new Date().getTime();

Expand All @@ -60,7 +60,7 @@ function max_mi_gx(t) {
let dist_rows = dist(matrices[timestep]);
// let transpose = reorder.transpose(matrices[timestep]),
// dist_cols = reorder.dist()(transpose);
let order = reorder.optimal_leaf_order(),
let order = reorder.nn_2opt(),
row_perm = order.distanceMatrix(dist_rows)(matrices[timestep]);
// let col_perm = order.distanceMatrix(dist_cols)(transpose);
let end = new Date().getTime();
Expand Down
1 change: 1 addition & 0 deletions nbproject/private/private.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
browser=Chrome.INTEGRATED
15 changes: 15 additions & 0 deletions nbproject/private/private.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/C:/Users/20184261/Documents/reorder.js/examples/timeseries/index.html</file>
<file>file:/C:/Users/20184261/Documents/reorder.js/src/nn_2opt.js</file>
<file>file:/C:/Users/20184261/Documents/reorder.js/examples/miserables/index.html</file>
<file>file:/C:/Users/20184261/Documents/reorder.js/test/nn_2opt-test.js</file>
<file>file:/C:/Users/20184261/Documents/reorder.js/examples/timeseries/order_functions.js</file>
<file>file:/C:/Users/20184261/Documents/reorder.js/examples/matrix.js</file>
<file>file:/C:/Users/20184261/Documents/reorder.js/src/optimal_leaf_order.js</file>
</group>
</open-files>
</project-private>
5 changes: 4 additions & 1 deletion src/nn_2opt.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function nn_2opt() {
if (distanceMatrix === null) {
distanceMatrix = dist().distance(distance)(matrix);
}
let lowest_dist = -1;
let lowest_dist = Number.MIN_VALUE;
let best_order = [];
// Try each row as the initial permutation
for (let s = 0; s < distanceMatrix.length; s++) {
Expand Down Expand Up @@ -83,6 +83,7 @@ export function nn_2opt() {
}
}
}
console.log(best_order);
return best_order;
}

Expand All @@ -103,5 +104,7 @@ export function nn_2opt() {
return nn_2opt;
};

nn_2opt.distanceMatrix = nn_2opt.distance_matrix; // compatability

return nn_2opt;
}

0 comments on commit a442807

Please sign in to comment.