From 2c9914989f4a22c43d28d4e821ee01ee00c7c5b5 Mon Sep 17 00:00:00 2001 From: anquetil Date: Sun, 8 Dec 2024 13:53:44 +0100 Subject: [PATCH] changed order of entities in matrix --- ...dencyStructuralMatrixBrowserModel.class.st | 37 ++++++++----------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/src/MooseIDE-Dependency/MiDependencyStructuralMatrixBrowserModel.class.st b/src/MooseIDE-Dependency/MiDependencyStructuralMatrixBrowserModel.class.st index a546e9b7..977ce073 100644 --- a/src/MooseIDE-Dependency/MiDependencyStructuralMatrixBrowserModel.class.st +++ b/src/MooseIDE-Dependency/MiDependencyStructuralMatrixBrowserModel.class.st @@ -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 }