gert-spanning-tree
v1.0.0
Published
Finds rooted spanning trees of undirected Gert graphs
Downloads
11
Maintainers
Readme
gert-spanning-tree
Finds rooted spanning trees of undirected Gert graphs
Usage
var Graph = require('gert').Graph;
var Spanning = require('gert-spanning-tree');
var graph = new Graph({
directed: false,
vertices: ['a', 'b', 'c', 'd'],
edges: [
['a', 'b'], ['b', 'c'],
['c', 'a'], ['c', 'd']
]
});
var spanningTree = Spanning(graph, 'a');
spanningTree.getEdges(null, true); // [['a', 'b'], ['a', 'c'], ['c', 'd']]
API
Spanning(graph, root, [depthFirst])
Returns a spanning tree of undirected Gert graph graph
rooted at vertex root
. If depthFirst
is true
then the vertices will be traversed depth-first rather than breadth-first.