Skip to content

Commit

Permalink
Closes elastic#62878 in Service Maps by improving the selection algor…
Browse files Browse the repository at this point in the history
…ithm for root nodes
  • Loading branch information
ogupte committed Apr 7, 2020
1 parent 898504d commit a8a52ac
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,15 @@ function getLayoutOptions(
}

function selectRoots(cy: cytoscape.Core): string[] {
const nodes = cy.nodes();
const roots = nodes.roots();
const rumNodes = nodes.filter(node => isRumAgentName(node.data(AGENT_NAME)));
return rumNodes.union(roots).map(node => node.id());
const bfs = cy.elements().bfs({
roots: cy.elements().leaves()
});
const furthestNodeFromLeaves = bfs.path.last();
return cy
.elements()
.roots()
.union(furthestNodeFromLeaves)
.map(el => el.id());
}

export function Cytoscape({
Expand Down

0 comments on commit a8a52ac

Please sign in to comment.