Find ring structures in reasonably sized graphs, such as molecular graphs. Works in node and in the browser.
npm install hanser-ring-finder
component install viatropos/hanser-ring-finder
This simple graph structure creates a triangle with an extra edge sticking out (so there is one cycle and one extra edge):
var graph =nodes:id: 0id: 1id: 2id: 3edges:source: 0 target: 1source: 1 target: 2source: 2 target: 0source: 3 target: 0 ;
Then just pass that into the hanser function and it will return a set of arrays containing the indices of nodes that create a complete cycle:
var hanser = ;var cycles = ;// [ [ 0, 2, 1 ] ]
var mol = ;var hanser = ;var graph = ; // mol file stringvar cycles = ;