dagrejs / graphlib

A directed multi-graph library for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

prim algorithm returns directed Graph

Brice187 opened this issue · comments

The API references this algorithm as follows:

Prim's algorithm takes a connected undirected graph and generates a minimum spanning tree. This function returns the minimum spanning tree as an _undirected graph_.

I run the algorithm with following example code:

console.log(query_set)
var prim_test = graphlib.alg.prim(query_set, function (weight) { return 1 / query_set.edge(weight) });
console.log(prim_test);

I get following result:

Console:

-> Graph {_isDirected: false, _isMultigraph: false, _isCompound: false, _label: undefined, _defaultNodeLabelFn: ƒ, …} <--- query set
-> Graph {_isDirected: true, _isMultigraph: false, _isCompound: false, _label: undefined, _defaultNodeLabelFn: ƒ, …}

so the resulting graph of this algorithm is directed