Skip to content

Commit

Permalink
Fix issue #387: o(n^2) implementation improved by using set operation
Browse files Browse the repository at this point in the history
  • Loading branch information
LaraMerdol committed Oct 18, 2023
1 parent 8fad035 commit 776dc83
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/app/visuall/cytoscape.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ export class CytoscapeService {
let compoundEdgeIds2 = this._g.cy.edges('.' + C.COLLAPSED_EDGE_CLASS).map(x => x.id());
elemIds.push(...C.arrayDiff(compoundEdgeIds, compoundEdgeIds2));
// elements might already exist but hidden, so show them
this._g.viewUtils.show(this._g.cy.nodes().filter(node => elemIds.includes(node.id())));
const elemIdSet = new Set(elemIds);
this._g.viewUtils.show(this._g.cy.nodes().filter(node => elemIdSet.has(node.id())));
this._g.applyClassFiltering();

if (isIncremental && !wasEmpty) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/visuall/db-service/neo4j-db.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Neo4jDb implements DbService {
const requestType = responseType == DbResponseType.graph ? 'graph' : 'row';
this._g.setLoadingStatus(true);
const timeout = this._g.userPrefs.dbTimeout.getValue() * 1000;
let q = isTimeboxed
const q = isTimeboxed
? `CALL apoc.cypher.run("${query}", null ) YIELD value RETURN value`
: query;
console.log(q);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ export class AdvancedQueriesComponent implements OnInit, OnDestroy {
}

private highlightSeedNodes() {
const dbIds = this.selectedNodes.map(x => x.dbId);
const seedNodes = this._g.cy.nodes().filter(node => dbIds.includes(node.id().substring(1)));
const dbIds = new Set(this.selectedNodes.map(x => x.dbId));
const seedNodes = this._g.cy.nodes().filter(node => dbIds.has(node.id().substring(1)));
// add a new higlight style
if (this._g.userPrefs.highlightStyles.length < 2) {
const cyStyle = getCyStyleFromColorAndWid('#0b9bcd', 4.5);
Expand All @@ -312,11 +312,11 @@ export class AdvancedQueriesComponent implements OnInit, OnDestroy {

private highlightTargetRegulators(data) {
const idxTargetRegulator = data.columns.indexOf('targetRegulatorNodeIds');
const dbIds = data.data[0][idxTargetRegulator];
if (!dbIds || dbIds.length < 1) {
const dbIds = new Set(data.data[0][idxTargetRegulator]);
if (!dbIds || dbIds.size < 1) {
return;
}
const cyNodes = this._g.cy.nodes().filter(node => dbIds.includes(node.id().substring(1)));
const cyNodes = this._g.cy.nodes().filter(node => dbIds.has(node.id().substring(1)));

// add a new higlight style
if (this._g.userPrefs.highlightStyles.length < 3) {
Expand Down

0 comments on commit 776dc83

Please sign in to comment.