graph.js icon indicating copy to clipboard operation
graph.js copied to clipboard

Other traversal algorithms

Open dominicbarnes opened this issue 9 years ago • 2 comments

Do any of the methods here accomplish either a depth-first or breadth-first traversal directly? It doesn't seem like that is the case, although there are clearly other algorithms sprinkled in.

If they are not included, is it because they are not difficult to implement by hand?

dominicbarnes avatar Oct 20 '15 05:10 dominicbarnes

Just searching around, I've come to discover a lot more tree traversal algorithms.

I suppose issue is similar to (if not an outright duplicated of) #8. Do you think this library will expose some sort of "plugin" infrastructure to add different algorithms? Or are you thinking that these libraries are standalone?

var Graph = require('graph.js');
var DFT = require('depth-first-traversal');

var graph = new Graph();

// standalone
DFT(graph, function (key, value) {
  // visit vertex
});

// plugin
graph.use(DFT);
graph.walk('depth-first', function (key, value) {
  // visit vertex
});

dominicbarnes avatar Oct 20 '15 06:10 dominicbarnes

Probably both.

DFT(graph, () => { ... });
Graph.plugin(DFT);
graph.DFT(() => { ... });

mhelvens avatar Oct 20 '15 09:10 mhelvens