This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Force directed graph layout algorithm according to Fruchterman and Reingold's principle. | |
* The algorithm can be summarized as follows: | |
* algorithm SPRING(G:graph); | |
* place vertices of G in random locations; | |
* repeat N times | |
* calculate the force on each vertex; | |
* move the vertex c4 | |
* draw graph on canvas, plotter or any drawing tool. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface Func<a, b> { | |
f: (_: a) => b | |
then: <c>(this: Func<a, b>, g: Func<b, c>) => Func<a, c> | |
repeat: (this: Func<a, a>) => Func<number, Func<a, a>> | |
repeatUntil: (this: Func<a, a>) => Func<Func<a, boolean>, Func<a, a>> | |
} | |
export let Func = <a, b>(f: (_: a) => b): Func<a, b> => { | |
return { | |
f: f, |