Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Add two feature flags for the visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminaaron committed Jul 18, 2023
1 parent e24744a commit 939d11b
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions subgroups-visualization.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
let n = 10;

let people = [];
let binaries = [];
let subgroups = {};
let nodes = [];
let edges = [];

let subgroupCenterNode = false;
let connectSubgroupCenters = false;

for (let i = 0; i < n; i++) {
people.push("Person_" + i)
}
Expand All @@ -32,17 +36,22 @@
}
}
subgroups[binary] = subgroup;
binaries.push(binary);
}

for (let key in subgroups) {
if (subgroups.hasOwnProperty(key)) {
let subgroup = subgroups[key];
// nodes
for (let key of binaries) {
let subgroup = subgroups[key];
// nodes
for (let i = 0; i < subgroup.length; i++) {
let person = subgroup[i];
nodes.push({ id: key + "_" + i, name: person });
}
if (subgroupCenterNode) {
nodes.push({ id: key, name: "subgroup" });
for (let i = 0; i < subgroup.length; i++) {
let person = subgroup[i];
nodes.push({ id: key + "_" + i, name: person });
edges.push({ source: key, target: key + "_" + i });
}
// edges
} else {
for (let i = 0; i < subgroup.length; i++) {
for (let j = i + 1; j < subgroup.length; j++) {
edges.push({ source: key + "_" + i, target: key + "_" + j });
Expand All @@ -51,6 +60,14 @@
}
}

if (connectSubgroupCenters) {
for (let i = 0; i < binaries.length; i++) {
for (let j = i + 1; j < binaries.length; j++) {
edges.push({ source: binaries[i], target: binaries[j] });
}
}
}

// console.log(nodes, edges);

let graphDiv = document.getElementById("graph");
Expand Down

0 comments on commit 939d11b

Please sign in to comment.