Commit ed69013d authored by Fintan Mc Gee's avatar Fintan Mc Gee

aqligned multiLayerGraph.js and graph.js files

parent 398ba317
......@@ -546,8 +546,7 @@ var MultiLayerGraph = function (nodes, links, layerName) {
diff.links.push(l);
}
});
g.buildNodeLookUp();
g.buildLinkLookUp();
g.refreshLookups();
//g.prepareGraph(); //should NEVER be exeuted on server
return diff;
}
......@@ -2851,7 +2850,6 @@ var MultiLayerGraph = function (nodes, links, layerName) {
nodeList.forEach(function(n2) {
// get nodes in target layer
var sourceID, targetID;
if(n1 < n2) {
......@@ -2887,12 +2885,7 @@ var MultiLayerGraph = function (nodes, links, layerName) {
existingLink.weight = newLinkWeightMap[newID]++;
}
}
// change its source/target to the new ones
});
});
......@@ -2967,7 +2960,6 @@ var MultiLayerGraph = function (nodes, links, layerName) {
layerNames = [layerNames];
}
// c
layerNames.forEach(function(layerName) {
var l = g.getLayerByName(layerName)
......@@ -3301,6 +3293,16 @@ var MultiLayerGraph = function (nodes, links, layerName) {
layer.clearLookups();
});
}
g.refreshLookups = function() {
g.clearLookups();
g.buildNodeLookUp();
g.buildLinkLookUp();
g.layers.forEach(function(layer) {
layer.buildNodeLookUp();
layer.buildLinkLookUp();
});
}
g.setUID();
g.buildNodeLookUp();
g.buildLinkLookUp();
......
......@@ -2074,6 +2074,8 @@ var MultiLayerGraph = function (nodes, links, layerName) {
}
}
}
console.log("Completed InterLayer Map Remove");
};
/**************************************
......@@ -3034,11 +3036,11 @@ var MultiLayerGraph = function (nodes, links, layerName) {
}
g.aspects[aspectName].forEach(function(existingLayer) {
if (!layerNames.find(existingLayer, function (currentInputLayer) {
if (!layerNames.find( function (currentInputLayer) {
if(usingReferences) {
return currentInputLayer === existingLayer.name;
}
return currentInputLayer === existingLayer.name;
return currentInputLayer === existingLayer;
})) {
updateLayersArray.push(existingLayer);
}
......@@ -3050,6 +3052,61 @@ var MultiLayerGraph = function (nodes, links, layerName) {
/** deleteAspect
*
* Functionality: Removes all layer form existing aspect, and all thoose layer from the master layer , and removes the aspect form the list of aspects
* @param aspectName : The tname of the aspect form whihc the layer should be removed
* * @return none
*
* Created By : Fintan McGee (LIST)
* Date: 06/12/2018
*/
g.deleteAspect = function(aspectName) {
if (!g.aspects.hasOwnProperty(aspectName)) {
console.log("Error:removeLayersFromAspect was called for an unrecognised aspect");
return;
}
if (g.name != "MasterLayer") {
console.log("Error:removeLayersFromAspect was called on layer other than master");
return;
}
var updateLayersArray = [];
var usingReferences = false;
if(g.aspects["Master"].length) {
if (typeof(g.aspects["Master"][0]) === "object") {
usingReferences = true;
}
}
var aspectLayers = [];
g.aspects[aspectName].forEach(function(existingLayer) {
if(usingReferences) {
aspectLayers.push(existingLayer.name);
} else {
aspectLayers.push(existingLayer);
}
});
g.removeLayersFromAspect(aspectName, aspectLayers);
g.removeLayersFromAspect("Master", aspectLayers);
aspectLayers.forEach(function(layerName){
g.deleteLayer(layerName);
})
g.aspects["Master"] = g.layers;
var newAspectsObj = {};
for(var existingAspectName in g.aspects) {
if (existingAspectName !== aspectName) {
newAspectsObj[existingAspectName] = g.aspects[existingAspectName];
}
}
g.aspects = newAspectsObj
// g.aspects[aspectName] = updateLayersArray;
}
/**************************************
* mapLinkEndsToNodeIds
* Functionality: WHen graph json is to be sent the vertices are mapped to edges by reference ,
......@@ -3075,11 +3132,11 @@ var MultiLayerGraph = function (nodes, links, layerName) {
g.mapAspectsToLayerReferences = function() {
if (g.name != "MasterLayer") {
console.log("Error:mapAspectsToLayerReferences was called on layer other than master");
//console.log("Error:mapAspectsToLayerReferences was called on layer other than master");
return;
}
var aspectsByRef = {};
g.aspects = {"Master":[]} ; // so it skipped in the search
g.aspects["Master"] =[] ; // so it skipped in the search
for (var aspectName in g.aspects) {
aspectsByRef[aspectName] = [];
g.aspects[aspectName].forEach (function(layerName){
......@@ -3092,7 +3149,7 @@ var MultiLayerGraph = function (nodes, links, layerName) {
aspectsByRef[aspectName].push(layerRef);
});
}
g.aspects = {"Master":g.layers} ;
g.aspects["Master"] = g.layers ;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment