Introducing subgraphs

This commit is contained in:
knsv
2015-01-07 21:02:58 +01:00
parent 273eb63efb
commit 5a720b6d63
12 changed files with 770 additions and 457 deletions

View File

@@ -5,6 +5,7 @@
var vertices = {};
var edges = [];
var classes = [];
var subGraphs = [];
var direction;
// Functions to be run after graph rendering
var funs = [];
@@ -197,6 +198,7 @@ exports.clear = function () {
classes = {};
edges = [];
funs = [];
subGraphs = [];
};
/**
*
@@ -205,3 +207,29 @@ exports.clear = function () {
exports.defaultStyle = function () {
return "fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;";
};
/**
* Clears the internal graph db so that a new graph can be parsed.
*/
exports.addSubGraph = function (list) {
function uniq(a) {
var prims = {"boolean":{}, "number":{}, "string":{}}, objs = [];
return a.filter(function(item) {
var type = typeof item;
if(type in prims)
return prims[type].hasOwnProperty(item) ? false : (prims[type][item] = true);
else
return objs.indexOf(item) >= 0 ? false : objs.push(item);
});
}
var subG = [];
subG = uniq(subG.concat.apply(subG,list));
subGraphs.push(subG);
};
exports.getSubGraphs = function (list) {
return subGraphs;
};