network-collection
Version:
Baseline collection of graphs and network data structures using **socket.io**.
23 lines (20 loc) • 424 B
JavaScript
;
const uuid = require('node-uuid');
class Node {
constructor(data, options) {
options = options || {};
this.edges = options.edges || {};
this.id = options.id || uuid.v4();
this.data = data || {};
}
addEdge(nodeId) {
this.edges[nodeId] = nodeId;
}
removeEdge(nodeId) {
delete this.edges[nodeId];
}
getEdge(toId) {
return this.edges[toId];
}
}
module.exports = Node;