Changer les paramètres
This commit is contained in:
@@ -2,6 +2,10 @@ import Graph from "graphology";
|
||||
import Sigma from "sigma";
|
||||
import forceAtlas2 from "graphology-layout-forceatlas2";
|
||||
|
||||
const p_pref = 0.45; // 0.45
|
||||
const p_triadic = 0.45; // 0.40
|
||||
const p_similitude = 1 - p_pref - p_triadic;
|
||||
|
||||
let individus: any[] = [];
|
||||
let graph: Graph;
|
||||
let sigma: Sigma;
|
||||
@@ -89,7 +93,7 @@ async function animateLinks() {
|
||||
|
||||
const N = individus.length;
|
||||
|
||||
for (let k = 0 ; k < N * 10 ; k++) {
|
||||
for (let k = 0 ; k < N * 15 ; k++) {
|
||||
if (!running) break;
|
||||
|
||||
const i = Math.floor(Math.random() * N);
|
||||
@@ -98,12 +102,10 @@ async function animateLinks() {
|
||||
console.log(`${i} ? ${j}`);
|
||||
|
||||
if (i === j) {
|
||||
console.log(`${i} == ${j}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (graph.hasEdge(String(i), String(j))) {
|
||||
console.log(`${i} hasEdge ${j}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -119,7 +121,7 @@ async function animateLinks() {
|
||||
|
||||
const diffEtudes = Math.abs(a.etudes - b.etudes) / 3;
|
||||
const diffRichesse = Math.abs(a.richesse - b.richesse) / 3;
|
||||
const similitude = 1 - (diffSexe * 2 + diffAge * 2 + diffLecture + diffMusique + diffSport + diffEtudes + diffRichesse) / 9;
|
||||
const similitude = 1 - (diffSexe * 2 + diffAge * 2 + diffLecture + diffMusique + diffSport * 4 + diffEtudes + diffRichesse) / 12;
|
||||
|
||||
// Attachement préférentiel
|
||||
const degreeA = graph.degree(String(i)) + 1;
|
||||
@@ -133,10 +135,10 @@ async function animateLinks() {
|
||||
const triadic = Math.min(common / 3, 0.5);
|
||||
|
||||
// Probabilité globale
|
||||
const p = 0.15 * similitude + 0.45 * pref + 0.4 * triadic;
|
||||
const p = p_similitude * similitude + p_pref * pref + p_triadic * triadic;
|
||||
const r = Math.random();
|
||||
|
||||
console.log(`${similitude} ${pref} ${triadic} ${p} (>${r})`);
|
||||
//console.log(`${similitude} ${pref} ${triadic} ${p} (>${r})`);
|
||||
|
||||
if (r < p) {
|
||||
individus[i].edges++;
|
||||
|
||||
Reference in New Issue
Block a user