-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sorting of nodes by number of edges #3847
- Loading branch information
1 parent
ed6f9cc
commit 6839b4c
Showing
2 changed files
with
39 additions
and
9 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...odeCharta/state/selectors/accumulatedData/metricData/sortedNodeEdgeMetricsMap.selector.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { createSelector } from "@ngrx/store" | ||
import { visibleFileStatesSelector } from "../../visibleFileStates/visibleFileStates.selector" | ||
import { blacklistSelector } from "../../../store/fileSettings/blacklist/blacklist.selector" | ||
import { calculateEdgeMetricData } from "./edgeMetricData.calculator" | ||
|
||
export const sortedNodeEdgeMetricsMapSelector = createSelector( | ||
visibleFileStatesSelector, | ||
blacklistSelector, | ||
(visibleFileStates, blacklist) => { | ||
const { nodeEdgeMetricsMap } = calculateEdgeMetricData(visibleFileStates, blacklist) | ||
|
||
const sortedNodeEdgeMetricsMap = new Map() | ||
|
||
for (const [key, value] of nodeEdgeMetricsMap) { | ||
const newSortedEdgeMetricEntry = new Map( | ||
[...value.entries()].sort((a, b) => { | ||
const aCount = a[1].incoming + a[1].outgoing | ||
const bCount = b[1].incoming + b[1].outgoing | ||
return bCount - aCount | ||
}) | ||
) | ||
sortedNodeEdgeMetricsMap.set(key, newSortedEdgeMetricEntry) | ||
} | ||
|
||
return sortedNodeEdgeMetricsMap | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters