graph = {
const roleNames = ['CEO', 'CFO', 'CTO', 'COO', 'CMO'];
const roles = roleNames.map((name, id) => ({id: id + 1, name, type: 'role'}));
const userNames = ['John', 'Tom', 'Jack', 'Pam', 'Jill', 'Chad', 'Bill', 'Mike', 'Dana', 'Mary'];
const users = userNames.map((name, id) => ({id: id + 10, name, type: 'user' }));
const nodes = [...roles, ...users];
const n = (name) => nodes.find(n => n.name === name).id;
const l = (source, target, access) => [
{source: n(source), target: n(target), value: 1, color: accessHash[access].color, access},
];
const links = roleNames.flatMap(role => {
const shuffled = shuffle(userNames);
const own = shuffled[0];
const part = Math.trunc(Math.random()*(shuffled.length-2)) + 1;
const vis = shuffled.slice(1, part);
const hid = shuffled.slice(part);
return [
...l(own, role, 'owned'),
...vis.flatMap(usr => l(usr, role, 'visible')),
...hid.flatMap(usr => l(usr, role, 'hidden')),
];
});
return { nodes, links}
}