Skip to content

Commit

Permalink
add edgesum measure
Browse files Browse the repository at this point in the history
  • Loading branch information
jdfekete committed May 6, 2015
1 parent 1f9ccca commit 99931c9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/edgesum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
reorder.edgesum = function(graph, order) {
if (! order)
order = reorder.range(graph.nodes().length);

var inv = inverse_permutation(order),
links = graph.links(),
i, e, d, sum = 0;

for (i = 0; i < links.length; i++) {
e = links[i];
d = Math.abs(inv[e.source.index]-inv[e.target.index]);
sum += d;
}
return sum;
};

0 comments on commit 99931c9

Please sign in to comment.