docs: large graph demo

This commit is contained in:
Yanyan-Wang 2020-11-17 20:09:52 +08:00 committed by Yanyan Wang
parent 431fcbb2a7
commit 42fd41e2da

View File

@ -1279,7 +1279,6 @@ const LargeGraph = () => {
.then((data) => { .then((data) => {
const nodeMap = {}, aggregatedNodeMap = {}; const nodeMap = {}, aggregatedNodeMap = {};
const clusteredData = louvain(data, false, 'weight'); const clusteredData = louvain(data, false, 'weight');
console.log(clusteredData);
const aggregatedData = { nodes: [], edges: [] }; const aggregatedData = { nodes: [], edges: [] };
clusteredData.clusters.forEach((cluster, i) => { clusteredData.clusters.forEach((cluster, i) => {
cluster.nodes.forEach(node => { cluster.nodes.forEach(node => {
@ -1300,7 +1299,6 @@ const LargeGraph = () => {
aggregatedData.nodes.push(cnode); aggregatedData.nodes.push(cnode);
}); });
clusteredData.clusterEdges.forEach(clusterEdge => { clusteredData.clusterEdges.forEach(clusterEdge => {
console.log('clusteredge', clusterEdge.source, clusterEdge.target)
const cedge = { const cedge = {
...clusterEdge, ...clusterEdge,
size: Math.log(clusterEdge.count as number), size: Math.log(clusterEdge.count as number),
@ -1322,7 +1320,6 @@ const LargeGraph = () => {
}); });
const { edges: processedEdges } = processNodesEdges(aggregatedData.nodes, aggregatedData.edges, CANVAS_WIDTH, CANVAS_HEIGHT, largeGraphMode, true, true); const { edges: processedEdges } = processNodesEdges(aggregatedData.nodes, aggregatedData.edges, CANVAS_WIDTH, CANVAS_HEIGHT, largeGraphMode, true, true);
console.log('processedEdges', processedEdges, aggregatedData.edges)
const contextMenu = new G6.Menu({ const contextMenu = new G6.Menu({
getContent(evt) { getContent(evt) {
@ -1338,9 +1335,9 @@ const LargeGraph = () => {
</ul>`; </ul>`;
} else { } else {
return `<ul> return `<ul>
<li id='neighbor1'></li> <li id='neighbor-1'></li>
<li id='neighbor2'></li> <li id='neighbor-2'></li>
<li id='neighbor3'></li> <li id='neighbor-3'></li>
<li id='hide'></li> <li id='hide'></li>
</ul>`; </ul>`;
} }
@ -1353,8 +1350,8 @@ const LargeGraph = () => {
}, },
handleMenuClick: (target, item) => { handleMenuClick: (target, item) => {
const model = item.getModel(); const model = item.getModel();
const id = model.id; const liIdStrs = target.id.split('-')
switch (target.id) { switch (liIdStrs[0]) {
case 'hide': case 'hide':
graph.hideItem(item); graph.hideItem(item);
break; break;
@ -1367,6 +1364,7 @@ const LargeGraph = () => {
handleRefreshGraph(graph, { nodes: resNodes, edges: resEdges }, CANVAS_WIDTH, CANVAS_HEIGHT, largeGraphMode, true, true); handleRefreshGraph(graph, { nodes: resNodes, edges: resEdges }, CANVAS_WIDTH, CANVAS_HEIGHT, largeGraphMode, true, true);
break; break;
case 'neighbor': case 'neighbor':
const expandNeighborSteps = parseInt(liIdStrs[1]);
break; break;
default: default:
break; break;