gert-spanning-tree

1.0.0 • Public • Published

gert-spanning-tree

Finds rooted spanning trees of undirected Gert graphs

Build Status Coverage Status

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.

Package Sidebar

Install

npm i gert-spanning-tree

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • devinivy