Correction d'affichage des voisins, pseudo-récursif.
This commit is contained in:
parent
45b5c17e72
commit
fd6cb9b73b
|
@ -10,27 +10,38 @@ var SOCIOGRAM = {
|
||||||
nodes: null,
|
nodes: null,
|
||||||
edges: null
|
edges: null
|
||||||
};
|
};
|
||||||
|
|
||||||
/* (0.5) Surcharge graph */
|
/* (0.5) Surcharge graph */
|
||||||
// On recupere les voisins d'un noeud
|
// On recupere les voisins d'un noeud
|
||||||
sigma.classes.graph.addMethod('nodeNeighbors', function(nodeId){
|
sigma.classes.graph.addMethod('nodeNeighbors', function(nodeId){
|
||||||
// On recupere les voisins du noeud courant
|
// On recupere les voisins du noeud courant
|
||||||
var neighbors = this.allNeighborsIndex[nodeId];
|
var neighbors = this.allNeighborsIndex[nodeId];
|
||||||
var tmp = neighbors;
|
|
||||||
|
|
||||||
// Et on recupere les voisins des voisins
|
// Pile des voisins pour lesquels il faut chercher leurs voisins
|
||||||
for( subnodeId in tmp ){
|
var stack = [];
|
||||||
var subneighbors = this.allNeighborsIndex[subnodeId];
|
for( neighborId in neighbors ) stack.push(neighborId);
|
||||||
for( subneighbor in subneighbors )
|
|
||||||
neighbors[subneighbor] = subneighbors[subneighbor];
|
// Tant qu'il reste des voisins a trouver
|
||||||
|
while( stack.length > 0 ){
|
||||||
|
var subneighbors = this.allNeighborsIndex[stack[0]];
|
||||||
|
for( subId in subneighbors )
|
||||||
|
// Si le voisin est pas deja dans la liste/pile, on l'ajoute a la liste des voisins
|
||||||
|
if( neighbors[subId] == null ){
|
||||||
|
stack.push(subId); // On ajoute a la pile
|
||||||
|
neighbors[subId] = subneighbors[subId]; // On ajoute a la liste complete
|
||||||
|
}
|
||||||
|
|
||||||
|
stack.shift();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// On retourne le resultat
|
// On retourne le resultat
|
||||||
return neighbors;
|
return neighbors;
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
/* (0.8) Initialisation de SIGMA */
|
/* (0.8) Initialisation de SIGMA */
|
||||||
SOCIOGRAM.sigma = new sigma({renderer: { container:SOCIOGRAM.container, 'type': 'canvas' }});
|
SOCIOGRAM.sigma = new sigma({renderer: { container: SOCIOGRAM.container, 'type': 'canvas' }});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,8 +120,8 @@ api.send(SOCIOGRAM.request, function(response){
|
||||||
neighborNodes[nodeId] = e.data.node; // on ajoute le noeud clique
|
neighborNodes[nodeId] = e.data.node; // on ajoute le noeud clique
|
||||||
|
|
||||||
SOCIOGRAM.sigma.graph.nodes().forEach(function(n) {
|
SOCIOGRAM.sigma.graph.nodes().forEach(function(n) {
|
||||||
if( neighborNodes[n.id] ) n.color = n.originalColor;
|
if( neighborNodes[n.id] != null ) n.color = n.originalColor;
|
||||||
else n.color = '#eee';
|
else n.color = '#eee';
|
||||||
});
|
});
|
||||||
|
|
||||||
SOCIOGRAM.sigma.refresh();
|
SOCIOGRAM.sigma.refresh();
|
||||||
|
|
Loading…
Reference in New Issue