Skip to content

Commit

Permalink
NN-612 Create Subgraphs and hide unconnected subgraphs
Browse files Browse the repository at this point in the history
  • Loading branch information
TripZz committed Nov 19, 2024
1 parent 2af836f commit eef6483
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions frontend/src/graph/GraphDataProvider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { Graph } from "graphology";
import louvain from 'graphology-communities-louvain';
import {circlepack} from 'graphology-layout';
import {largestConnectedComponent} from 'graphology-components';
import betweennessCentrality from 'graphology-metrics/centrality/betweenness';
import pagerank from 'graphology-metrics/centrality/pagerank';
import chroma from "chroma-js";
Expand Down Expand Up @@ -43,9 +44,10 @@
}
);
}
this.generateGraphLayout();
this.generateGraphStatistics();
this.generateGraphColor();
this.generateGraphLayout(graph);
this.generateGraphStatistics(graph);
this.generateGraphColor(graph);
this.generateSubgraph(graph);
testgraph.forEachNode((node, attr) => {
const size = testgraph.degree(node);
Expand Down Expand Up @@ -81,6 +83,19 @@
pagerank.assign(graph);
},
generateSubgraph(graph){
/* Filters the highest connected component and hides all unconnected nodes.
Input: graph: graphObject
*/
const largest = new Set(largestConnectedComponent(testgraph));
graph.forEachNode((node) => {
!largest.has(node)
? graph.setNodeAttribute(node, 'hidden', true)
: graph.removeNodeAttribute(node, 'hidden');
});
},
generateGraphColor(graph){
/* Creates colorpalette with chroma.js and assign each node their respective color (community).
Input: graph: graphObject
Expand Down

0 comments on commit eef6483

Please sign in to comment.