Wrapping around the graph-data-structure library to work with graphs

main
CSDUMMI 2022-03-22 09:08:30 +01:00
rodzic 5f9e1d74ba
commit 48e8cdf4ae
1 zmienionych plików z 25 dodań i 0 usunięć

25
src/Graph.js 100644
Wyświetl plik

@ -0,0 +1,25 @@
const Graph = require("graph-data-structure");
class GraphIndex {
/**
* Wrapper around the graph-data-structure
* that parses the oplog to create a corresponding
* Graph.
*/
constructor() {
this._graph = Graph();
}
addProject(cid) {
this._graph.addNode(cid)
}
addDependency(dependent, dependency, weight) {
this._graph.addEdge(dependent, depedency, weight)
}
get projects() {
return this._graph.nodes()
}
}