Skip to content

Commit

Permalink
Merge pull request #16 from astares/15-Cleanup-unnecessary-tabs-space…
Browse files Browse the repository at this point in the history
…s-and-final-dots

Cleanup unnecessary tabs, spaces and final dots
  • Loading branch information
jordanmontt authored Jan 3, 2023
2 parents 7a6f0d1 + 847057e commit 5be86f6
Show file tree
Hide file tree
Showing 33 changed files with 204 additions and 209 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ AIDisjointSetNode >> find [

"Compress the path leading back to the root.
This is the path compression operation that gives the linear amortized time complexity"
[ node = root ] whileFalse: [
[ node = root ] whileFalse: [
next := node parent.
node parent: root.
node := next ].
Expand Down
2 changes: 1 addition & 1 deletion src/AI-Algorithms-Graph-Components/AIGraphEdge.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ AIGraphEdge class >> with: aModel from: srcNode to: dstNode [
edge model: aModel.
edge from: srcNode.
edge to: dstNode.
^ edge.
^ edge
]

{ #category : #accessing }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ AIReducedGraphNode >> printOn: stream [

stream nextPutAll: self label.
model isCollection
ifTrue: [
ifTrue: [
model
do: [ :node | node printOn: stream ]
separatedBy: [ stream << ', ' ] ]
Expand Down
4 changes: 2 additions & 2 deletions src/AI-Algorithms-Graph-Generators/AI2DGridNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ AI2DGridNode >> x [
]

{ #category : #accessing }
AI2DGridNode >> x: anInteger [
AI2DGridNode >> x: anInteger [
x := anInteger
]

Expand All @@ -27,6 +27,6 @@ AI2DGridNode >> y [
]

{ #category : #accessing }
AI2DGridNode >> y: anInteger [
AI2DGridNode >> y: anInteger [
y := anInteger
]
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ AIAlbertBarabasiGraphGenerator >> run [

self nodes: (1 to: m0).
self nodes
do: [ :n1 |
do: [ :n1 |
self nodes
do: [ :n2 |
do: [ :n2 |
n1 ~= n2
ifTrue: [
ifTrue: [
self
addEdge:
{(n1 model).
(n2 model)}
from: #first
to: #second ] ] ].


to: #second ] ] ]
]
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ AIAtlasGraphGenerator >> edgesArray: anArray [
{ #category : #running }
AIAtlasGraphGenerator >> run [
edgesArray
do: [ :edge |
do: [ :edge |
self
addEdge:
{edge first.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ AIErdosRenyiGNMGraphGenerator >> run [
"https://en.wikipedia.org/wiki/Erd%C5%91s%E2%80%93R%C3%A9nyi_model"

edgesNumber
timesRepeat: [
timesRepeat: [
| source target |
source := self nodes atRandom.
target := ((self nodes copy)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ AIErdosRenyiGNPGraphGenerator >> run [
"https://en.wikipedia.org/wiki/Erd%C5%91s%E2%80%93R%C3%A9nyi_model"

self nodes
do: [ :n1 |
do: [ :n1 |
self nodes
do: [ :n2 |
do: [ :n2 |
n1 ~= n2
ifTrue: [
ifTrue: [
100 atRandom / 100 < probability
ifTrue: [
ifTrue: [
self
addEdge:
{n1 model.
Expand Down
20 changes: 10 additions & 10 deletions src/AI-Algorithms-Graph-Generators/AIGrid2DGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Class {
AIGrid2DGenerator >> buildMooreNeighborhood [
| graph |
graph := self nodes.
2 to: width do: [ :i |
2 to: height do: [ :j |
2 to: width do: [ :i |
2 to: height do: [ :j |
self
addEdge:
{(graph at: (j - 1) * width + i) model.
Expand All @@ -38,7 +38,7 @@ AIGrid2DGenerator >> buildMooreNeighborhood [
to: #second ] ].

"Link upper nodes"
1 to: width - 1 do: [ :i |
1 to: width - 1 do: [ :i |
self
addEdge:
{(graph at: i) model.
Expand All @@ -47,15 +47,15 @@ AIGrid2DGenerator >> buildMooreNeighborhood [
to: #second ].

"Link left nodes"
1 to: height - 1 do: [ :i |
1 to: height - 1 do: [ :i |
self
addEdge:
{(graph at: (i - 1) * width + 1) model.
(graph at: (i - 1) * width + 1 + width) model}
from: #first
to: #second ].
1 to: width - 1 do: [ :i |
2 to: height do: [ :j |
1 to: width - 1 do: [ :i |
2 to: height do: [ :j |
self
addEdge:
{(graph at: (j - 1) * width + i) model.
Expand All @@ -68,8 +68,8 @@ AIGrid2DGenerator >> buildMooreNeighborhood [
AIGrid2DGenerator >> buildVonNeumannNeighorhood [
| graph |
graph := self nodes.
2 to: width do: [ :i |
2 to: height do: [ :j |
2 to: width do: [ :i |
2 to: height do: [ :j |
self
addEdge:
{(graph at: (j - 1) * width + i) model.
Expand All @@ -84,7 +84,7 @@ AIGrid2DGenerator >> buildVonNeumannNeighorhood [
to: #second ] ].

"Link upper nodes"
1 to: width - 1 do: [ :i |
1 to: width - 1 do: [ :i |
self
addEdge:
{(graph at: i) model.
Expand All @@ -93,7 +93,7 @@ AIGrid2DGenerator >> buildVonNeumannNeighorhood [
to: #second ].

"Link left nodes"
1 to: height - 1 do: [ :i |
1 to: height - 1 do: [ :i |
self
addEdge:
{(graph at: (i - 1) * width + 1) model.
Expand Down
24 changes: 12 additions & 12 deletions src/AI-Algorithms-Graph-Generators/AIGrid3DGenerator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Class {
AIGrid3DGenerator >> buildVonNeumannNeighorhood [
| graph |
graph := self nodes.
1 to: length - 1 do: [ :i |
1 to: height - 1 do: [ :j |
1 to: width - 1 do: [ :k |
1 to: length - 1 do: [ :i |
1 to: height - 1 do: [ :j |
1 to: width - 1 do: [ :k |
self
addEdge:
{(graph at: i + ((j - 1) * length) + ((k - 1) * length * height)) model.
Expand All @@ -40,8 +40,8 @@ AIGrid3DGenerator >> buildVonNeumannNeighorhood [
to: #second ] ] ].

"Right plane"
1 to: height - 1 do: [ :j |
1 to: width - 1 do: [ :k |
1 to: height - 1 do: [ :j |
1 to: width - 1 do: [ :k |
self
addEdge:
{(graph at: length + ((j - 1) * length) + ((k - 1) * length * height)) model.
Expand All @@ -56,8 +56,8 @@ AIGrid3DGenerator >> buildVonNeumannNeighorhood [
to: #second ] ].

"Top plan"
1 to: length - 1 do: [ :i |
1 to: height - 1 do: [ :j |
1 to: length - 1 do: [ :i |
1 to: height - 1 do: [ :j |
self
addEdge:
{(graph at: i + ((j - 1) * length) + ((width - 1) * length * height)) model.
Expand All @@ -71,8 +71,8 @@ AIGrid3DGenerator >> buildVonNeumannNeighorhood [
from: #first
to: #second ] ].
"Back Plane"
1 to: length - 1 do: [ :i |
1 to: width - 1 do: [ :k |
1 to: length - 1 do: [ :i |
1 to: width - 1 do: [ :k |
self
addEdge:
{(graph at: i + ((height - 1) * length) + ((k - 1) * length * height)) model.
Expand All @@ -87,15 +87,15 @@ AIGrid3DGenerator >> buildVonNeumannNeighorhood [
to: #second ] ].

"Rigth Edge"
1 to: width - 1 do: [ :k |
1 to: width - 1 do: [ :k |
self
addEdge:
{(graph at: length + ((height - 1) * length) + ((k - 1) * length * height)) model.
(graph at: length + ((height - 1) * length) + (k * length * height)) model}
from: #first
to: #second ].
"Top Edge"
1 to: height - 1 do: [ :j |
1 to: height - 1 do: [ :j |
self
addEdge:
{(graph at: length + ((j - 1) * length) + ((width - 1) * length * height)) model.
Expand All @@ -104,7 +104,7 @@ AIGrid3DGenerator >> buildVonNeumannNeighorhood [
to: #second ].

"Top Back Edge"
1 to: length - 1 do: [ :i |
1 to: length - 1 do: [ :i |
self
addEdge:
{(graph at: i + ((height - 1) * length) + ((width - 1) * length * height)) model.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ AIHexagonalLatticeGenerator >> buildLinks [
"Connect each nodes to nodes that are in 2 steps "

nodes
do: [ :each |
do: [ :each |
| links |
"Build the top of hexagon"
(each y \\ 4 = 1 and: [ each x \\ 2 = 1 ])
ifTrue: [ "and: [ each x \\ 2 = 1 ]"
links := self nodesAtDistance: 2 toNode: each.
links
do: [ :node |
do: [ :node |
node y > each y
ifTrue: [ self
addEdge:
Expand All @@ -44,7 +44,7 @@ AIHexagonalLatticeGenerator >> buildLinks [
ifTrue: [ "and: [ each x \\ 2 = 1 ]"
links := self nodesAtDistance: 2 toNode: each.
links
do: [ :node |
do: [ :node |
node y > each y
ifTrue: [ self
addEdge:
Expand All @@ -57,7 +57,7 @@ AIHexagonalLatticeGenerator >> buildLinks [
ifTrue: [ "and: [ each x \\ 2 = 1 ]"
links := self nodesOnColumnAtDistance: 1 toNode: each.
links
do: [ :node |
do: [ :node |
self
addEdge:
{each model.
Expand All @@ -69,7 +69,7 @@ AIHexagonalLatticeGenerator >> buildLinks [
ifTrue: [ "and: [ each x \\ 2 = 1 ]"
links := self nodesOnColumnAtDistance: 1 toNode: each.
links
do: [ :node |
do: [ :node |
self
addEdge:
{each model.
Expand All @@ -88,7 +88,7 @@ AIHexagonalLatticeGenerator >> initializeNodesOnGrid [
| nbNodes |
nbNodes := 1.
nodes
do: [ :each |
do: [ :each |
each x: (nbNodes - 1) \\ n + 1.
each y: (nbNodes - 1 quo: n) + 1.
nbNodes := nbNodes + 1 ]
Expand Down Expand Up @@ -127,7 +127,7 @@ AIHexagonalLatticeGenerator >> nodesAtDistance: aDistance toNode: aNode [
i := aNode x.
j := aNode y.
^ nodes
select: [ :each |
select: [ :each |
k := each x.
l := each y.
((k - i) raisedTo:2) + ((l - j) raisedTo:2) = aDistance ]
Expand All @@ -141,7 +141,7 @@ AIHexagonalLatticeGenerator >> nodesOnColumnAtDistance: aDistance toNode: aNode
i := aNode x.
j := aNode y.
^ nodes
select: [ :each |
select: [ :each |
k := each x.
l := each y.
i = k and: [ l - j = aDistance ] ]
Expand All @@ -152,7 +152,7 @@ AIHexagonalLatticeGenerator >> removeUnnecessaryNodes [
| listeActiveNodes |
listeActiveNodes := OrderedCollection new.
nodes
do: [ :each |
do: [ :each |
(each y \\ 4 = 0 and: [ each x \\ 2 = 1 ])
ifTrue: [ listeActiveNodes add: each ].
(each y \\ 4 = 1 and: [ each x \\ 2 = 1 ])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ AIKleinbergGraphGenerator >> buildLocalLinks [
"Connect each nodes to nodes that are in p steps (following the manhattan distance)"

nodes
do: [ :each |
do: [ :each |
| links |
links := self nodesLessThanDistance: p toNode: each.
links
do: [ :node |
do: [ :node |
self
addEdge:
{each model.
Expand All @@ -50,15 +50,15 @@ AIKleinbergGraphGenerator >> buildLongRangeLinks [
"Build q long range links for each nodes"

|probs cdf |
q == 0 ifFalse: [
q == 0 ifFalse: [
r == 0
ifTrue: [ self buildUniformDistributionOfLongRangeLinks ]
ifFalse: [ nodes
do: [ :n1 |
probs := #(0) asOrderedCollection.
do: [ :n1 |
probs := #(0) asOrderedCollection.
nodes do: [ :n2 |
|d|
n1 == n2 ifFalse: [
n1 == n2 ifFalse: [
d := self distanceFrom: n1 to:n2.
probs add: (d raisedTo: r negated).
]].
Expand All @@ -69,8 +69,8 @@ q == 0 ifFalse: [
self addEdge:
{n1 model . target model}
from: #first
to: #second
]
to: #second
]
] ]
]
]
Expand Down Expand Up @@ -111,7 +111,7 @@ AIKleinbergGraphGenerator >> initializeNodesOnGrid [
| nbNodes |
nbNodes := 1.
nodes
do: [ :each |
do: [ :each |
each x: (nbNodes - 1) \\ n + 1.
each y: (nbNodes - 1 quo: n) + 1.
nbNodes := nbNodes + 1]
Expand All @@ -129,7 +129,7 @@ AIKleinbergGraphGenerator >> n: anInteger [

{ #category : #configuration }
AIKleinbergGraphGenerator >> nodeClass [
^ AI2DGridNode
^ AI2DGridNode
]

{ #category : #running }
Expand All @@ -139,7 +139,7 @@ AIKleinbergGraphGenerator >> nodesLessThanDistance: aDistance toNode: aNode [
| i j k l |
i := aNode x.
j := aNode y.

^nodes select: [ : each|
k := each x.
l := each y.
Expand Down
Loading

0 comments on commit 5be86f6

Please sign in to comment.