Public
Edited
Feb 27, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// function get_cycleList(nodes, links, neighList){
// // build the list of cyclebours for each nodes of the graph
// // returns an array of indexed by nodes
// // debugger;
// let cycleList = new Array(nodes.length);
// // debugger;
// for (const node of nodes){
// let cyclebours = new Array();
// let neighbours = neighList[+node.index];
// // cyclebours.push(+node);
// for (let len=2; len < 5; len++){
// let cycles = get_cycles(len, +node.index, neighList);
// if (typeof cycles[0] !== []){
// cycles.map((cycle) => cyclebours.push(cycle));
// }
// }
// if (cyclebours.length) cycleList[node.index] = cyclebours;
// }
// // cycleList = cycleList.filter(d=>typeof d !== 'undefined');
// return cycleList;
// }
Insert cell
function get_neighList(nodes, links){
// build the list of neighbours for each nodes of the graph
// returns an array of indexed by nodes
let neighList = new Array(nodes.length);
for (let node in nodes) {
let neighbours = new Array();
neighbours.push(nodes[node].index);
for (let i=0; i<links.length; i++) {
if (links[i].sourceId === nodes[node].index) {
neighbours.push(links[i].targetId);
}
if (links[i].targetId === nodes[node].index) {
neighbours.push(links[i].sourceId);
}
}
// console.log(neighbours);
// filter out empty
if (neighbours.length > 1)
neighList[node] = neighbours;
}
return neighList;
}
Insert cell
// function get_cycles(longueur, vertex, neighList){
// // renvois les cycles commençant en vertex et de longueur définie
// // debugger;
// let paths = get_voisinage_rec(longueur, new Array([vertex]), neighList);
// let cycles = new Array();
// if (typeof paths !== 'undefined'){
// paths.forEach(function(path){
// if (path.slice(-1)[0] === vertex) cycles.push(path.slice(0,-1));
// });
// }
// return cycles;
// }
Insert cell
// function get_voisinage_rec(distance, voisinages, neighList){
// // Une fonction réccursive qui renvois les chemins exactement de longueur distances
// if (distance === 0) return voisinages;
// let new_voisinages = new Array();
// for(let i in voisinages){
// let voisinage = voisinages[i];
// let cv = voisinage.slice(-1)[0]; // current vertex
// let voisins = neighList[cv];
// if (typeof voisins !== 'undefined'){
// voisins.forEach(function(new_voize){
// if (new_voize != cv){
// // ajoute au nouveau voisinage l'ancier plus le nouveau voisin
// new_voisinages.push(voisinage.concat([new_voize]));
// }
// });
// distance--;
// return get_voisinage_rec(distance, new_voisinages, neighList);
// };
// }
// }
Insert cell
// function is_node_in_cyclebours(cyclebours, vertex){
// // on parcours les cycle de la nodes touché
// if (typeof cyclebours === "undefined") return false;
// for (const cycle of cyclebours){
// // si la node en question est dans l'un des cycles c'est ok
// if (cycle.includes(vertex.index)) return true;
// }
// return false;
// }
Insert cell
// function is_edge_in_cyclebours(cyclebours, edge){
// // on parcours les cycle de la nodes touché
// let source = edge.source.index;
// let target = edge.target.index;
// if (typeof cyclebours === "undefined") return false;
// for (const cycle of cyclebours){
// // si la node en question est dans l'un des cycles c'est ok
// let i = cycle.indexOf(source);
// if (i < cycle.length -1){
// if (cycle[i+1] === target) return true;
// /* else if last of list (which does not contain le first element but we know
// is a cycle) */
// }else if (cycle[0] === target) return true;
// }
// return false;
// }

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more