Commit 18ba0e00 authored by PkSM3's avatar PkSM3

edge weight social filter finally ok

parent b3481133
......@@ -131,7 +131,7 @@
/* ZOOM IN OUT */
#ctlzoom {
position: absolute; right: 220px; bottom: 5px; list-style: none; padding: 0; margin: 0;/*EDIT*/
position: absolute; right: 300px; bottom: 5px; list-style: none; padding: 0; margin: 0;/*EDIT*/
}
#ctlzoom li {
......
......@@ -23,12 +23,12 @@ box-shadow: 0px 0px 3px 0px #888888;
#leftcolumn {
overflow-y: scroll;
margin-right: -210px;
margin-right: -300px;
margin-left: 0px;
padding-bottom: 10px;
padding-left: 5px;
right: 210px;
width: 210px;
right: 300px;
width: 300px;
position: fixed;
height: 100%;
border: 1px #888888 solid;
......
......@@ -6,6 +6,7 @@
<title>TinawebJS</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="utf-8">
<link rel="stylesheet" href="jquery/jquery-ui.css" media="screen">
<link rel="stylesheet" href="css/bootstrap.css" media="screen">
<link rel="stylesheet" href="css/freshstyle.css" media="screen">
......
This diff is collapsed.
# -*- coding: utf-8 -*-
from FA2 import ForceAtlas2
from extractData import extract as SQLite
import json
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
def main():
#query = request.args['query']
#{"categorya"%3A"Keywords"%2C"categoryb"%3A"Scholars"%2C"keywords"%3A[]%2C"countries"%3A["Chile"]%2C"laboratories"%3A[]%2C"coloredby"%3A[]%2C"tags"%3A[]%2C"organizations"%3A[]}
# i=int(sys.argv[2])
# unique_id = sys.argv[1]
# db=SQLite(unique_id)
# db.extract()
# < Data Extraction > #
i = 100
unique_id = "Carla__Taramasco"#"Noël__Bonneuil"
db=SQLite(unique_id)
db.extract()
# < / Data Extraction > #
tempGraph = db.buildSimpleJSONFinal(db.Graph)
# Arnaud Banos network:
# Bruce Edmonds exists twice, but one of them has no keywords
# import pprint as p
# A=tempGraph["edges"]
# for j in A:
# s=j["source"]
# t=j["target"]
# if s=="D::593" or t=="D::593":
# print j
# spatialized = ForceAtlas2(tempGraph)
# spatialized.init()
# spatialized.getGraph()
# for i in range(0,i):
# spatialized.atomicGo()
graphArray = db.buildJSON_sansfa2(db.Graph)
# A=graphArray["edges"]
# for j in A:
# print A[j]
#
# print "finish"
return json.dumps(graphArray)
if __name__ == "__main__":
main()
......@@ -665,19 +665,20 @@ class extract:
return graph
def buildJSON_sansfa2(self,graph,coordsRAW):
def buildJSON_sansfa2(self,graph,coordsRAW=None):
print "printing in buildJSON_sansfa2()"
nodes = {}
edges = {}
import json
xy = coordsRAW #For FA2.java: json.loads(coordsRAW)
#print xy
coords = {}
for i in xy:
coords[i['sID']] = {}
coords[i['sID']]['x'] = i['x']
coords[i['sID']]['y'] = i['y']
#print coords
if coordsRAW:
import json
xy = coordsRAW #For FA2.java: json.loads(coordsRAW)
#print xy
coords = {}
for i in xy:
coords[i['sID']] = {}
coords[i['sID']]['x'] = i['x']
coords[i['sID']]['y'] = i['y']
#print coords
for idNode in graph.nodes_iter():
if idNode[0]=="N":#If it is NGram
......@@ -691,8 +692,8 @@ class extract:
node["label"] = nodeLabel
node["color"] = "19,"+str(colorg)+",244"
node["term_occ"] = term_occ
node["x"] = str(coords[idNode]['x'])
node["y"] = str(coords[idNode]['y'])
if coordsRAW: node["x"] = str(coords[idNode]['x'])
if coordsRAW: node["y"] = str(coords[idNode]['y'])
nodes[idNode] = node
......@@ -732,7 +733,7 @@ class extract:
if self.scholars[idNode]['homepage'][0:3] == "www":
content += '[ <a href=http://' +self.scholars[idNode]['homepage'].replace("&"," and ")+ ' target=blank > View homepage </a ><br/>]'
elif self.scholars[idNode]['homepage'][0:4] == "http":
content += '[ <a href=' +self.scholars[idNode]['homepage'].replace("&"," and ")+ ' target=blank > View homepage </a ><br/>]'
content += '[ <a href=' +self.scholars[idNode]['homepage'].replace("&"," and ")+ ' target=blank > View homepage </a >]<br/>'
node = {}
......@@ -740,19 +741,39 @@ class extract:
node["label"] = nodeLabel
node["color"] = color
node["term_occ"] = "12"
node["x"] = str(coords[idNode]['x'])
node["y"] = str(coords[idNode]['y'])
if coordsRAW: node["x"] = str(coords[idNode]['x'])
if coordsRAW: node["y"] = str(coords[idNode]['y'])
node["content"] = self.toHTML(content)
nodes[idNode] = node
GG = nx.Graph()
for n in self.Graph.edges_iter():
s = n[0]
t = n[1]
w = float(self.Graph[n[0]][n[1]]['weight'])
tp = self.Graph[n[0]][n[1]]['type']
if GG.has_edge(s,t):
oldw = GG[s][t]['weight']
avgw = (oldw+w)/2
GG[s][t]['weight'] = avgw
else:
GG.add_edge( s , t , { "weight":w , "type":tp } )
e = 0
for n in self.Graph.edges_iter():#Memory, what's wrong with you?
weight = str("%.2f" % self.Graph[n[0]][n[1]]['weight'])
for n in GG.edges_iter():#Memory, what's wrong with you?
wr = 0.0
origw = GG[n[0]][n[1]]['weight']
for i in range(2,10):
wr = round( origw , i)
if wr > 0.0: break
edge = {}
edge["s"] = n[0]
edge["t"] = n[1]
edge["w"] = str(self.Graph[n[0]][n[1]]['weight'])
edge["type"] = self.Graph[n[0]][n[1]]['type']
edge["w"] = str(wr)
edge["type"] = GG[n[0]][n[1]]['type']
if edge["type"]=="nodes1": print wr
edges[str(e)] = edge
e+=1
#if e%1000 == 0:
......@@ -964,7 +985,7 @@ class extract:
nodes2.append(node)
nodes[idNode] = countnodes
countnodes+=1
e = 0
e = 0
for n in self.Graph.edges_iter():#Memory, what's wrong with you?
weight = str("%.2f" % self.Graph[n[0]][n[1]]['weight'])
edge = {}
......
......@@ -52,16 +52,16 @@ def main():
# if s=="D::593" or t=="D::593":
# print j
spatialized = ForceAtlas2(tempGraph)
spatialized.init()
# spatialized = ForceAtlas2(tempGraph)
# spatialized.init()
spatialized.getGraph()
# spatialized.getGraph()
# for i in range(0,i):
# spatialized.atomicGo()
graphArray = db.buildJSON_sansfa2(db.Graph,spatialized.getGraph())
graphArray = db.buildJSON_sansfa2(db.Graph)
return json.dumps(graphArray)
......
......@@ -45,39 +45,38 @@ var desirableScholarSize=6; //Remember that all scholars have the same size!
* - true: fa2 running at start
* - false: fa2 stopped at start, button exists
* - "off": button doesn't exist, fa2 stopped forever
**/
var fa2enabled="off";
**/ var fa2enabled=false;//"off";
var stopcriteria = false;
var iterationsFA2=1000;
var seed=999999999;//defaultseed
var showLabelsIfZoom=2.0;
// ============ < SIGMA.JS PROPERTIES > ============
var desirableNodeSizeMIN=1;
var desirableNodeSizeMAX=12;
var desirableScholarSize=6; //Remember that all scholars have the same size!
var sigmaJsDrawingProperties = {
defaultLabelColor: 'black',
defaultLabelSize: 10,//in fact I'm using it as minLabelSize'
defaultLabelBGColor: '#fff',
defaultLabelHoverColor: '#000',
labelThreshold: 6,
defaultEdgeType: 'curve',
borderSize: 2.5,//Something other than 0
nodeBorderColor: "default",//exactly like this
defaultNodeBorderColor: "black"//,//Any color of your choice
//defaultBorderView: "always"
};
var sigmaJsGraphProperties = {
minEdgeSize: 2,
maxEdgeSize: 2
};
var sigmaJsMouseProperties = {
minRatio:0.1,
maxRatio: 100
};
// ============ < / SIGMA.JS PROPERTIES > ============
// ============ < SIGMA.JS PROPERTIES > ============
var sigmaJsDrawingProperties = {
defaultLabelColor: 'black',
defaultLabelSize: 10,//in fact I'm using it as minLabelSize'
defaultLabelBGColor: '#fff',
defaultLabelHoverColor: '#000',
labelThreshold: 6,
defaultEdgeType: 'curve',
borderSize: 2.5,//Something other than 0
nodeBorderColor: "default",//exactly like this
defaultNodeBorderColor: "black"//,//Any color of your choice
//defaultBorderView: "always"
};
var sigmaJsGraphProperties = {
minEdgeSize: 2,
maxEdgeSize: 2
};
var sigmaJsMouseProperties = {
minRatio:0.1,
maxRatio: 15
};
// ============ < / SIGMA.JS PROPERTIES > ============
// ============ < / DEVELOPER OPTIONS > ============
......@@ -108,6 +107,18 @@ var swMacro=true;
var socsemFlag=false;
var constantNGramFilter;
// var nodeFilterA_past = ""
// var nodeFilterA_now = ""
// var nodeFilterB_past = ""
// var nodeFilterB_now = ""
var lastEdgeFilterA = "-"
// var edgeFilterB_past = ""
// var edgeFilterB_now = ""
var overviewWidth = 200;
var overviewHeight = 175;
......
This diff is collapsed.
$("#zoomSlider").slider({
orientation: "vertical",
value: 10,
min: 0,
max: 100,
range: "min",
step: 1,
slide: function( event, ui ) {
console.log("ui.value : "+ui.value)
}
});
......@@ -337,8 +337,84 @@ function justhide(){
//=========================== < FILTERS-SLIDERS > ===========================//
function OrganizeEdgeWeightsForSlider( edgtype ) {
// ( 1 )
// get visible sigma edges
visible_edges=partialGraph._core.graph.edges.filter(function(e) {
return !e['hidden'] && e["label"]==edgtype;
});
// ( 2 )
// extract [ "edgeID" : edgeWEIGHT ]
// and save this into edges_weight
var edges_weight=[]
for (var i in visible_edges) {
e = visible_edges[i]
id = e.id
edges_weight[id]=e.weight
// pr(id+"\t:\t"+e.weight)
}
// ( 3 )
// order dict edges_weight by edge weight
var result = ArraySortByValue(edges_weight, function(a,b){
return a-b
//ASCENDENT
});
// // ( 4 )
// printing ordered ASC by weigth
// for (var i in result) {
// r = result[i]
// edgeid = r.key
// edgeweight = r.value
// pr(edgeid+"\t:\t"+edgeweight)
// // e = result[i]
// // pr(e.weight)
// }
var nb_E = result.length
var magnitude = (""+nb_E).length //order of magnitude of #visibleedges
var exponent = magnitude - 1
var steps = Math.pow(10,exponent) // #(10 ^ magnit-1) steps
var stepsize = Math.round(nb_E/steps)// ~~(visibledges / #steps)
// pr("-----------------------------------")
// pr("number of visible edges: "+nb_E);
// pr("result array:")
// pr(result)
// pr("magnitude : "+magnitude)
// pr("number of steps : "+steps)
// pr("size of one step : "+stepsize)
// pr("-----------------------------------")
var finalarray = []
var counter=0
for(var i = 0; i < steps; i++) {
// pr(i)
var edgIDs = []
for(var j = 0; j < stepsize; j++) {
if(!isUndef(result[counter])) {
k = result[counter].key
// w = result[counter].value
// pr("\t["+counter+"] : "+w)
edgIDs.push(k)
}
counter++;
}
if(edgIDs.length==0) break;
finalarray[i] = edgIDs
}
return {"steps":finalarray.length,"finalarray":finalarray}
}
function updateEdgeFilter(edgeFilterName) {
pr("Updating filter_ "+edgeFilterName);
pr("nothing: Updating edge filter_ "+edgeFilterName);
/*
thing="";
if(edgeFilterName=="social") {
edgeFilterName="#sliderAEdgeWeight";
......@@ -445,9 +521,12 @@ function updateEdgeFilter(edgeFilterName) {
});
}
});
*/
}
function updateBothEdgeFilters() {
pr("nothing: Updating both edge filters");
/*
edges=partialGraph._core.graph.edges.filter(function(e) {
return !e['hidden'];
});;
......@@ -564,10 +643,12 @@ function updateBothEdgeFilters() {
});
}
});
*/
}
function updateNodeFilter(nodeFilterName) {
pr("nothing: Updating node filter_ "+nodeFilterName);
/*
scholarsNodesBySize=[];
keywordsNodesBySize=[];
nodesSortedBySize=[];
......@@ -638,9 +719,12 @@ function updateNodeFilter(nodeFilterName) {
// });
// }
// });
*/
}
function updateBothNodeFilters() {
pr("nothing: Updating both node filters");
/*
nodes=partialGraph._core.graph.nodes.filter(function(n) {
return !n['hidden'];
});
......@@ -727,6 +811,7 @@ function updateBothNodeFilters() {
});
}
});
*/
}
//=========================== </ FILTERS-SLIDERS > ===========================//
......
......@@ -70,7 +70,7 @@ function sigmaLimits(){
}
function bringTheNoise(pathfile,type){
// $('.modal').modal('show');
// $('.modal').modal('show');
// === get width and height === //
sigmaLimits();
......@@ -187,6 +187,7 @@ function bringTheNoise(pathfile,type){
if(type=="unique_id") {
pr("bring the noise, case: unique_id");
pr(getClientTime()+" : DataExt Ini");
// < === DATA EXTRACTION === >
$.ajax({
type: 'GET',
url: bridge["forNormalQuery"],
......@@ -231,22 +232,6 @@ function bringTheNoise(pathfile,type){
pr(getClientTime()+" : Fin FA2");
console.log("Parsing and FA2 complete.");
// < === ASYNCHRONOUS FA2.JS DONE!! === >
// // leftPanel("close");
// $("#closemodal").click();//modal.hide doesnt work :c
// // startForceAtlas2(partialGraph._core.graph);r(
// cancelSelection(false);
// $("#tips").html(getTips());
// //$('#sigma-example').css('background-color','white');
// $("#category-B").hide();
// $("#labelchange").hide();
// $("#availableView").hide();
// showMeSomeLabels(6);
// initializeMap();
// updateMap();
// updateDownNodeEvent(false);
// partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, 0.8).draw(2,2,2);
theListeners();
});
},
......@@ -279,35 +264,6 @@ function theListeners(){
saveGEXF();
});
// $("#aUnfold").click(function() {
// _cG = $("#leftcolumn");
// anchototal=$('#fixedtop').width();
// sidebar=_cG.width();
//
// if (_cG.offset().left < 0) {
// _cG.animate({
// "left" : sidebar+"px"
// }, function() {
// $("#aUnfold").attr("class","leftarrow");
// $('#sigma-example').width(anchototal-sidebar);
// $("#ctlzoom").css({
// left: (sidebar+10)+"px"
// });
// });
// } else {
// _cG.animate({
// "left" : "-" + _cG.width() + "px"
// }, function() {
// $("#aUnfold").attr("class","rightarrow");
// $('#sigma-example').width(anchototal);
// $("#ctlzoom").css({
// left: "0px"
// });
// });
// }
// return false;
// });
//
/******************* /SEARCH ***********************/
$.ui.autocomplete.prototype._renderItem = function(ul, item) {
var searchVal = $("#searchinput").val();
......@@ -431,7 +387,7 @@ function theListeners(){
}
});
// minimap stuff
// $("#overview")
// .mousemove(onOverviewMove)
// .mousedown(startMove)
......@@ -447,12 +403,8 @@ function theListeners(){
})
.contextmenu(function(){
return false;
});
// .mousemove(onOverviewMove)
// .mousedown(startMove)
// .mouseup(endMove)
// .mouseout(endMove)
// .mousewheel(onGraphScroll); -> it doesn't answer!
})
.mousewheel(onGraphScroll);
$(document).keydown(function(e) {
if( e.shiftKey || e.which==16 ) {
......@@ -478,23 +430,23 @@ function theListeners(){
range: "min",
step: 0.1,
slide: function( event, ui ) {
pr("*******lalala***********")
pr(partialGraph.position().ratio)
pr(sigmaJsMouseProperties.minRatio)
pr(sigmaJsMouseProperties.maxRatio)
// pr("*******lalala***********")
// pr(partialGraph.position().ratio)
// pr(sigmaJsMouseProperties.minRatio)
// pr(sigmaJsMouseProperties.maxRatio)
partialGraph.zoomTo(
partialGraph._core.width / 2,
partialGraph._core.height / 2,
ui.value);
}
});
$("#zoomPlusButton").click(function () {
partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 1.5);
$("#zoomSlider").slider("value",partialGraph.position().ratio);
return false;
});
$("#zoomMinusButton").click(function () {
partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 0.5);
$("#zoomSlider").slider("value",partialGraph.position().ratio);
......@@ -502,42 +454,93 @@ function theListeners(){
});
$("#edgesButton").click(function () {
if(fa2enabled===false){
edgesTF=true;
if(!fa2enabled){
fa2enabled=true;
}
if(edgesTF==false){
partialGraph.stopForceAtlas2();
partialGraph.draw();
edgesTF=true;
}
else {
partialGraph.startForceAtlas2();
edgesTF=false;
} else {
partialGraph.stopForceAtlas2();
}
});
//finished
$("#sliderANodeWeight").freshslider({
range: true,
step:1,
value:[10, 60],
enabled: false,
onchange:function(low, high){
console.log(low, high);
}
});
var filterparams = OrganizeEdgeWeightsForSlider ( "nodes1" )
var steps = filterparams["steps"]
var finalarray = filterparams["finalarray"]
//finished
$("#sliderAEdgeWeight").freshslider({
range: true,
step:1,
value:[10, 100],
onchange:function(low, high){
console.log(low, high);
step: 1,
min:0,
max:steps-1,
onchange:function(low, high){
var filtervalue = low+"-"+high
// pr("filterNOW: "+filtervalue+" | filterPAST: "+lastEdgeFilterA+" => "+(filtervalue!=lastEdgeFilterA))
if(filtervalue!=lastEdgeFilterA) {
if(lastEdgeFilterA=="-") {
pushEdgesFilterA(filtervalue)
return false
}
// $.doTimeout(300,function (){
for(var i in finalarray) {
ids = finalarray[i]
if(i>=low && i<=high){
for(var id in ids) {
edgeid = ids[id]
add1Edge(edgeid)
// partialGraph.addEdge(edgeid,Edges[edgeid].source,target,edge);
// unHideElem(edgeid)
}
} else {
for(var id in ids) {
edgeid = ids[id]
remove1Edge(edgeid)
// hideElem(edgeid)
}
}
}
pushEdgesFilterA(filtervalue)
partialGraph.refresh()
partialGraph.draw()
// });
}
// pr("filterNOW: "+filtervalue+" | filterPAST: "+lastEdgeFilterA+" => "+(filtervalue!=lastEdgeFilterA))
}
});
//finished
$("#sliderANodeSize").freshslider({
step:1,
value:10,
min:1,
max:25,
value:1,
onchange:function(value){
console.log(value);
$.doTimeout(100,function (){2
partialGraph.iterNodes(function (n) {
if(Nodes[n.id].type==catSoc) {
n.size = parseFloat(Nodes[n.id].size) + parseFloat((value-1))*0.3;
}
});
partialGraph.draw();
});
}
});
......@@ -549,6 +552,7 @@ function theListeners(){
console.log(low, high);
}
});
$("#sliderBEdgeWeight").freshslider({
range: true,
step:1,
......@@ -557,13 +561,26 @@ function theListeners(){
console.log(low, high);
}
});
//finished
$("#sliderBNodeSize").freshslider({
step:1,
value:20,
min:1,
max:25,
value:1,
onchange:function(value){
console.log(value);
$.doTimeout(100,function (){
partialGraph.iterNodes(function (n) {
if(Nodes[n.id].type==catSem) {
n.size = parseFloat(Nodes[n.id].size) + parseFloat((value-1))*0.3;
}
});
partialGraph.draw();
});
}
});
//finished
$("#unranged-value").freshslider({
step: 1,
min:cursor_size_min,
......@@ -626,17 +643,5 @@ function theListeners(){
// });
// }
// });
// $("#sliderSelectionZone").slider({
// value: cursor_size,
// min: parseFloat(cursor_size_min),
// max: parseFloat(cursor_size_max),
// animate: true,
// change: function(event, ui) {
// cursor_size= ui.value;
// //if(cursor_size==0) updateDownNodeEvent(false);
// //else updateDownNodeEvent(true);
// //return callSlider("#sliderSelectionZone", "selectionRadius");
// }
// });
}
This diff is collapsed.
......@@ -101,57 +101,58 @@ function endMove(evt){
}
function onGraphScroll(evt, delta) {
partialGraph.totalScroll += delta;
if (Math.abs(partialGraph.totalScroll) >= 1) {
if (partialGraph.totalScroll < 0) {
//ZoomOUT
if (partialGraph.position().ratio > sigmaJsMouseProperties.minRatio) {
//partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 0.5);
//var _el = $(this),
//_off = $(this).offset(),
//_deltaX = evt.pageX - _el.width() / 2 - _off.left,
//_deltaY = evt.pageY - _el.height() / 2 - _off.top;
var
mx=evt.offsetX,
my=evt.offsetY;
partialGraph.centreX=mx*((partialGraph._core.width-1)/(overviewWidth)),
partialGraph.centreY=my*((partialGraph._core.height-1)/(overviewHeight));
$("#zoomSlider").slider("value",partialGraph.position().ratio);
// partialGraph.totalScroll += delta;
// if (Math.abs(partialGraph.totalScroll) >= 1) {
// if (partialGraph.totalScroll < 0) {
// //ZoomOUT
// if (partialGraph.position().ratio > sigmaJsMouseProperties.minRatio) {
// //partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 0.5);
// //var _el = $(this),
// //_off = $(this).offset(),
// //_deltaX = evt.pageX - _el.width() / 2 - _off.left,
// //_deltaY = evt.pageY - _el.height() / 2 - _off.top;
// var
// mx=evt.offsetX,
// my=evt.offsetY;
// partialGraph.centreX=mx*((partialGraph._core.width-1)/(overviewWidth)),
// partialGraph.centreY=my*((partialGraph._core.height-1)/(overviewHeight));
// console.log("mx: "+mx+" - my: "+ my);
// console.log("cx: "+cx+" - cy: "+ cy);
// partialGraph.centreX =cx;
// partialGraph.centreY =cy;
partialGraph.zoomTo(partialGraph.centreX, partialGraph.centreY, partialGraph._core.mousecaptor.ratio * 0.5);
// partialGraph.centreX -= ( Math.SQRT2 - 1 ) * _deltaX / partialGraph.echelleGenerale;
// partialGraph.centreY -= ( Math.SQRT2 - 1 ) * _deltaY / partialGraph.echelleGenerale;
// partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 0.5);
$("#zoomSlider").slider("value",partialGraph.position().ratio);
}
} else {
//ZoomIN
if (partialGraph.position().ratio < sigmaJsMouseProperties.maxRatio) {
// partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 1.5);
// partialGraph.echelleGenerale = Math.pow( Math.SQRT2, partialGraph.position().ratio );
//var _el = $(this),
//_off = $(this).offset(),
//_deltaX = evt.pageX - _el.width() / 2 - _off.left,
//_deltaY = evt.pageY - _el.height() / 2 - _off.top;
var
mx=evt.offsetX,
my=evt.offsetY;
partialGraph.centreX=mx*((partialGraph._core.width-1)/(overviewWidth)),
partialGraph.centreY=my*((partialGraph._core.height-1)/(overviewHeight));
// // console.log("mx: "+mx+" - my: "+ my);
// // console.log("cx: "+cx+" - cy: "+ cy);
// // partialGraph.centreX =cx;
// // partialGraph.centreY =cy;
// partialGraph.zoomTo(partialGraph.centreX, partialGraph.centreY, partialGraph._core.mousecaptor.ratio * 0.5);
// // partialGraph.centreX -= ( Math.SQRT2 - 1 ) * _deltaX / partialGraph.echelleGenerale;
// // partialGraph.centreY -= ( Math.SQRT2 - 1 ) * _deltaY / partialGraph.echelleGenerale;
// // partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 0.5);
// $("#zoomSlider").slider("value",partialGraph.position().ratio);
// }
// } else {
// //ZoomIN
// if (partialGraph.position().ratio < sigmaJsMouseProperties.maxRatio) {
// // partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, partialGraph._core.mousecaptor.ratio * 1.5);
// // partialGraph.echelleGenerale = Math.pow( Math.SQRT2, partialGraph.position().ratio );
// //var _el = $(this),
// //_off = $(this).offset(),
// //_deltaX = evt.pageX - _el.width() / 2 - _off.left,
// //_deltaY = evt.pageY - _el.height() / 2 - _off.top;
// var
// mx=evt.offsetX,
// my=evt.offsetY;
// partialGraph.centreX=mx*((partialGraph._core.width-1)/(overviewWidth)),
// partialGraph.centreY=my*((partialGraph._core.height-1)/(overviewHeight));
// console.log("mx: "+mx+" - my: "+ my);
// console.log("cx: "+cx+" - cy: "+ cy);
// partialGraph.centreX =cx;
// partialGraph.centreY =cy;
partialGraph.zoomTo(partialGraph.centreX, partialGraph.centreY, partialGraph._core.mousecaptor.ratio * 1.5);
$("#zoomSlider").slider("value",partialGraph.position().ratio);
}
}
partialGraph.totalScroll = 0;
}
// // console.log("mx: "+mx+" - my: "+ my);
// // console.log("cx: "+cx+" - cy: "+ cy);
// // partialGraph.centreX =cx;
// // partialGraph.centreY =cy;
// partialGraph.zoomTo(partialGraph.centreX, partialGraph.centreY, partialGraph._core.mousecaptor.ratio * 1.5);
// $("#zoomSlider").slider("value",partialGraph.position().ratio);
// }
// }
// partialGraph.totalScroll = 0;
// }
}
function initializeMap() {
......
......@@ -248,7 +248,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph) {
var convg= ((Math.pow(nodes.length,2))/promdxdy); /**/
var swingingVSnodes_length = swingingSum/nodes.length; /**/
if(convg > swingingVSnodes_length){
if(stopcriteria && convg > swingingVSnodes_length){
if(numberOfDocs==nodes.length){
socialConverged++;
}
......@@ -963,11 +963,10 @@ sigma.forceatlas2.Region.prototype.applyForce = function(n, Force, theta) {
sigma.publicPrototype.startForceAtlas2 = function() {
//if(!this.forceatlas2) {
if(fa2enabled===true) {
if(fa2enabled) {
this.forceatlas2 = new sigma.forceatlas2.ForceAtlas2(this._core.graph);
this.forceatlas2.setAutoSettings();
this.forceatlas2.init();
//}
$("#overviewzone").hide();
this.addGenerator('forceatlas2', this.forceatlas2.atomicGo, function(){
return true;
......@@ -976,6 +975,7 @@ sigma.publicPrototype.startForceAtlas2 = function() {
};
sigma.publicPrototype.stopForceAtlas2 = function() {
fa2enabled=false;
this.removeGenerator('forceatlas2');
updateMap();
partialGraph.refresh();
......
......@@ -505,7 +505,7 @@ sigma.classes.Cascade = function() {
var counter=0;
var actualSel=[];
partialGraph.iterNodes(function(n){
if(n.hidden==false){
if(!n.hidden){
distance = Math.sqrt(
Math.pow((x1-parseInt(n.displayX)),2) +
Math.pow((y1-parseInt(n.displayY)),2)
......@@ -1167,6 +1167,7 @@ sigma.classes.Cascade = function() {
'source': self.nodesIndex[source],
'target': self.nodesIndex[target],
'size': 1,
'dead':false,
'weight': 1,
'displaySize': 0.5,
'color': color,
......@@ -1183,6 +1184,7 @@ sigma.classes.Cascade = function() {
for (var k in params) {
switch (k) {
case 'id':
case 'dead':
case 'source':
case 'target':
break;
......@@ -1202,6 +1204,7 @@ sigma.classes.Cascade = function() {
case 'label':
e[k] = params[k];
break;
default:
e['attr'][k] = params[k];
}
......@@ -1225,6 +1228,7 @@ sigma.classes.Cascade = function() {
'size': edge['size'],
'type': edge['type'],
'weight': edge['weight'],
'dead' : edge['dead'],
'displaySize': edge['displaySize'],
'label': edge['label'],
'hidden': edge['hidden'],
......@@ -1247,6 +1251,7 @@ sigma.classes.Cascade = function() {
for (var k in copy) {
switch (k) {
case 'id':
case 'dead':
case 'displaySize':
break;
case 'weight':
......
......@@ -671,57 +671,88 @@ function extractFromJson(data,seed){
if(edge.label=="nodes1"){
if( (typeof partialGraph._core.graph.edgesIndex[target+";"+source])=="undefined" ){
edge.hidden=false;
}
else edge.hidden=true;
if((typeof nodes1[source])=="undefined"){
if(edge.label=="nodes1"){
edge.hidden=false;
if(isUndef(nodes1[source])) {
nodes1[source] = {
label: Nodes[source].label,
neighbours: []
};
nodes1[source].neighbours.push(target);
};
}
else nodes1[source].neighbours.push(target);
if(isUndef(nodes1[target])) {
nodes1[target] = {
label: Nodes[target].label,
neighbours: []
};
}
nodes1[source].neighbours.push(target);
nodes1[target].neighbours.push(source);
}
if(edge.label=="nodes2"){
edge.hidden=true;
if((typeof nodes2[source])=="undefined"){
if(isUndef(nodes2[source])) {
nodes2[source] = {
label: Nodes[source].label,
neighbours: []
};
nodes2[source].neighbours.push(target);
};
}
else nodes2[source].neighbours.push(target);
if(isUndef(nodes2[target])) {
nodes2[target] = {
label: Nodes[target].label,
neighbours: []
};
}
nodes2[source].neighbours.push(target);
nodes2[target].neighbours.push(source);
}
if(edge.label=="bipartite"){
edge.hidden=true;
// Document to NGram
if((typeof bipartiteD2N[source])=="undefined"){
bipartiteD2N[source] = {
label: Nodes[source].label,
neighbours: []
};
s = edge.sourceID
// // Source is Document
if(Nodes[s].type == catSoc) {
if(isUndef(bipartiteD2N[source])) {
bipartiteD2N[source] = {
label: Nodes[source].label,
neighbours: []
};
}
if(isUndef(bipartiteN2D[target])) {
bipartiteN2D[target] = {
label: Nodes[target].label,
neighbours: []
};
}
bipartiteD2N[source].neighbours.push(target);
}
else bipartiteD2N[source].neighbours.push(target);
// NGram to Document
if((typeof bipartiteN2D[target])=="undefined"){
bipartiteN2D[target] = {
label: Nodes[target].label,
neighbours: []
};
bipartiteN2D[target].neighbours.push(source);
// // Source is NGram
} else {
if(isUndef(bipartiteN2D[source])) {
bipartiteN2D[source] = {
label: Nodes[source].label,
neighbours: []
};
}
if(isUndef(bipartiteD2N[target])) {
bipartiteD2N[target] = {
label: Nodes[target].label,
neighbours: []
};
}
bipartiteN2D[source].neighbours.push(target);
bipartiteD2N[target].neighbours.push(source);
}
else bipartiteN2D[target].neighbours.push(source);
}
//edge.hidden=false/**///should be commented
......
......@@ -54,6 +54,12 @@ function getedgesIndex(){
return partialGraph._core.graph.edgesIndex;
}
function getVisibleEdges() {
partialGraph._core.graph.edges.filter(function(e) {
return !e['hidden'];
});
}
function getn(id){
return partialGraph._core.graph.nodesIndex[id];
}
......
......@@ -31,7 +31,7 @@ function test2 {
for f in $iter
do
filename=`echo $f | sed s/"\.\/"//g`
variable=`cat $filename | grep "zoomTo"`
variable=`cat $filename | grep "edgesTF"`
if [[ "$variable" != "" ]]
then
echo $filename
......
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