Skip to content

Commit

Permalink
changed order of entities in matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
anquetil committed Dec 8, 2024
1 parent 4294130 commit 2c99149
Showing 1 changed file with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,39 +265,32 @@ MiDependencyStructuralMatrixBrowserModel >> orderNodes: nodeCollection [

"order nodes according to number of dependencies
Order is:
- first the less outgoing dependencies
- if equal, then first less incoming dependencies
- if equal, then alphabetical order"
- put first entities with less dependents (ignoring weights)
- put first entities with weaker dependents based on weights"

| inDependencies outDependencies |
inDependencies := Dictionary new: nodeCollection size.
outDependencies := Dictionary new: nodeCollection size.
| dependents weights |
dependents := Dictionary new: nodeCollection size.
weights := Dictionary new: nodeCollection size.

nodeCollection do: [ :node |
inDependencies at: node model put: 0.
outDependencies at: node model put: 0
dependents at: node model put: 0.
weights at: node model put: 0.
].

dependencyDictionary keysAndValuesDo: [ :tuple :dependencies |
dependencies ifNotEmpty: [
self increment: inDependencies key: tuple value value: 1.
self increment: outDependencies key: tuple key value: 1
self increment: dependents key: tuple value value: 1.
self increment: weights key: tuple value value: dependencies size.
]
].

^nodeCollection sorted: [ :nodeA :nodeB || outA inA outB inB|
outA := outDependencies at: nodeA model.
inA := inDependencies at: nodeA model.
outB := outDependencies at: nodeB model.
inB := inDependencies at: nodeB model.
"1halt."
(outA < outB)
or: [ (outA = outB)
ifTrue: [ (inA < inB)
or: [ (inA = inB) and: [nodeA model name < nodeB model name] ] ]
ifFalse: [ false ] ]
]
^nodeCollection sorted: [ :nodeA :nodeB || depsA depsB |
depsA := dependents at: nodeA model.
depsB := dependents at: nodeB model.

(depsA < depsB)
or: [ (depsA = depsB) and: [ (weights at: nodeA model) < (weights at: nodeB model) ] ]
]
]

{ #category : #accessing }
Expand Down

0 comments on commit 2c99149

Please sign in to comment.