-
Notifications
You must be signed in to change notification settings - Fork 357
frontend: Map: Add weights to GraphNodes #3389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
frontend: Map: Add weights to GraphNodes #3389
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: adwait-godbole The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice implementation! Thanks for taking a look.
I left a couple of small comments, but overall it looks good.
Oh and a couple of tests are failing
} | ||
|
||
// sort nodes by weight (descending) and return the highest weighted node | ||
const sortedByWeight = [...nodes].sort((a, b) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rewrite this function so that it doesn't create a copy and doesn't sort them all? It's possible to find a node with the biggest weight in linear time without allocating a new array
} | ||
|
||
// if weights are the same, fall back to the hardcoded hierarchy | ||
const deployment = nodes.find(it => it.kubeObject?.kind === 'Deployment'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think relying just on weight is better, we shouldn't have this fallback, especially since all of these kinds are covered already
* @param node - The GraphNode to get weight for | ||
* @returns The effective weight (higher = more important) | ||
*/ | ||
export function getNodeWeight(node: GraphNode): number { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can also be used for the layout, to determine in which order nodes are displayed. currently it's hardcoded in graphLayout.tsx:57 getPartitionLevel()
function. Would you mind also using it there? Not very important but would be nice, if you have time
047660b
to
c15efae
Compare
Signed-off-by: Adwait Godbole <[email protected]>
c15efae
to
4937582
Compare
Fixes #3369
After Weights:
Screencast.from.29-05-25.08.25.38.PM.IST.webm
After Weights:
Screencast.from.29-05-25.08.27.19.PM.IST.webm
cc @sniok @yolossn