Skip to content

Commit

Permalink
update for issue pharo-graphics/Roassal#4
Browse files Browse the repository at this point in the history
  • Loading branch information
akevalion committed Oct 23, 2023
1 parent 18915df commit 3d31904
Show file tree
Hide file tree
Showing 15 changed files with 247 additions and 233 deletions.
31 changes: 16 additions & 15 deletions src/Roassal-Layouts-Util/RSDSMGraph.class.st
Expand Up @@ -3,30 +3,31 @@ I am a class used to find strong connections beteween objects
based on https://www.geeksforgeeks.org/strongly-connected-components/
"
Class {
#name : #RSDSMGraph,
#superclass : #Object,
#name : 'RSDSMGraph',
#superclass : 'Object',
#instVars : [
'graph',
'numberOfVertices'
],
#category : #'Roassal-Layouts-Util'
#category : 'Roassal-Layouts-Util',
#package : 'Roassal-Layouts-Util'
}

{ #category : #'instance creation' }
{ #category : 'instance creation' }
RSDSMGraph class >> new: aNumber [
^ self new
numberOfVertices: aNumber;
yourself
]

{ #category : #adding }
{ #category : 'adding' }
RSDSMGraph >> addEdge: anInteger to: anInteger2 [
| collection |
collection := graph at: anInteger ifAbsentPut: [ OrderedCollection new ].
collection add: anInteger2
]

{ #category : #public }
{ #category : 'public' }
RSDSMGraph >> computeSCCs [
| stack visited gr groups |
groups := OrderedCollection new.
Expand All @@ -48,7 +49,7 @@ RSDSMGraph >> computeSCCs [
^ groups allButLast
]

{ #category : #utilties }
{ #category : 'utilties' }
RSDSMGraph >> dfsUtil: index visited: visited [
visited at: index put: true.
index trace.
Expand All @@ -58,7 +59,7 @@ RSDSMGraph >> dfsUtil: index visited: visited [
]
]

{ #category : #utilties }
{ #category : 'utilties' }
RSDSMGraph >> dfsUtil: index visited: visited groups: groups [
| lastGroup |
visited at: index put: true.
Expand All @@ -73,7 +74,7 @@ RSDSMGraph >> dfsUtil: index visited: visited groups: groups [
]
]

{ #category : #examples }
{ #category : 'examples' }
RSDSMGraph >> example01 [
<script: 'self new example01 inspect'>

Expand All @@ -88,7 +89,7 @@ RSDSMGraph >> example01 [
g printSCCs
]

{ #category : #examples }
{ #category : 'examples' }
RSDSMGraph >> example02 [
<script: 'self new example02 inspect'>

Expand All @@ -103,7 +104,7 @@ RSDSMGraph >> example02 [
^ g computeSCCs
]

{ #category : #private }
{ #category : 'private' }
RSDSMGraph >> fillOrder: index visited: visited stack: stack [
visited at: index put: true.
(graph at: index ifAbsent: [ #()]) do: [ :each |
Expand All @@ -113,7 +114,7 @@ RSDSMGraph >> fillOrder: index visited: visited stack: stack [
stack push: index
]

{ #category : #private }
{ #category : 'private' }
RSDSMGraph >> getTranspose [
| g |
g := self class new: numberOfVertices.
Expand All @@ -124,18 +125,18 @@ RSDSMGraph >> getTranspose [
^ g
]

{ #category : #initialization }
{ #category : 'initialization' }
RSDSMGraph >> initialize [
super initialize.
graph := Dictionary new
]

{ #category : #accessing }
{ #category : 'accessing' }
RSDSMGraph >> numberOfVertices: anInteger [
numberOfVertices := anInteger
]

{ #category : #public }
{ #category : 'public' }
RSDSMGraph >> printSCCs [
| stack visited gr |
stack := Stack new.
Expand Down
11 changes: 6 additions & 5 deletions src/Roassal-Layouts-Util/RSDirectLayoutTranslator.class.st
Expand Up @@ -2,17 +2,18 @@
TODO
"
Class {
#name : #RSDirectLayoutTranslator,
#superclass : #RSLayoutTranslator,
#category : #'Roassal-Layouts-Util'
#name : 'RSDirectLayoutTranslator',
#superclass : 'RSLayoutTranslator',
#category : 'Roassal-Layouts-Util',
#package : 'Roassal-Layouts-Util'
}

{ #category : #testing }
{ #category : 'testing' }
RSDirectLayoutTranslator class >> isDefault [
^ true
]

{ #category : #hook }
{ #category : 'hook' }
RSDirectLayoutTranslator >> translate: element to: newPosition [
element translateTo: newPosition
]
29 changes: 15 additions & 14 deletions src/Roassal-Layouts-Util/RSDummyNode.class.st
Expand Up @@ -2,15 +2,16 @@
A RODummyNode is used by the sugiyama layout
"
Class {
#name : #RSDummyNode,
#superclass : #Object,
#name : 'RSDummyNode',
#superclass : 'Object',
#instVars : [
'edge'
],
#category : #'Roassal-Layouts-Util'
#category : 'Roassal-Layouts-Util',
#package : 'Roassal-Layouts-Util'
}

{ #category : #'instance creation' }
{ #category : 'instance creation' }
RSDummyNode class >> on: anEdge slot: anIndex [

^(self new)
Expand All @@ -19,51 +20,51 @@ RSDummyNode class >> on: anEdge slot: anIndex [
yourself
]

{ #category : #accessing }
{ #category : 'accessing' }
RSDummyNode >> edge [
^ edge
]

{ #category : #accessing }
{ #category : 'accessing' }
RSDummyNode >> edge: anEdge [
edge := anEdge
]

{ #category : #accessing }
{ #category : 'accessing' }
RSDummyNode >> extent [
^ self height @ self width
]

{ #category : #accessing }
{ #category : 'accessing' }
RSDummyNode >> height [
^ 0
]

{ #category : #accessing }
{ #category : 'accessing' }
RSDummyNode >> position [
^ 0 @ 0
]

{ #category : #actions }
{ #category : 'actions' }
RSDummyNode >> signalUpdate [
"do nothing"
]

{ #category : #accessing }
{ #category : 'accessing' }
RSDummyNode >> slot: anIndex [
]

{ #category : #accessing }
{ #category : 'accessing' }
RSDummyNode >> translateBy: apoint [
"do nothing"
]

{ #category : #accessing }
{ #category : 'accessing' }
RSDummyNode >> translateTo: aPoint [
"edge index: index point: aPoint"
]

{ #category : #accessing }
{ #category : 'accessing' }
RSDummyNode >> width [
^ 0
]

0 comments on commit 3d31904

Please sign in to comment.