Skip to content

Commit

Permalink
Merge pull request #38 from astares/37-Cleanup-AIGraphReducerTestmerg…
Browse files Browse the repository at this point in the history
…edNodesIn-should-use-isNotNil

Cleanup: AIGraphReducerTest>>#mergedNodesIn: should use isNotNil
  • Loading branch information
jecisc authored Nov 22, 2023
2 parents 3029f27 + 536af26 commit 8b9f916
Show file tree
Hide file tree
Showing 28 changed files with 291 additions and 238 deletions.
26 changes: 14 additions & 12 deletions src/AI-Algorithms-Graph-Tests/AIAstarTest.class.st
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
Class {
#name : #AIAstarTest,
#superclass : #TestCase,
#name : 'AIAstarTest',
#superclass : 'TestCase',
#instVars : [
'astar'
],
#category : #'AI-Algorithms-Graph-Tests-Tests'
#category : 'AI-Algorithms-Graph-Tests-Tests',
#package : 'AI-Algorithms-Graph-Tests',
#tag : 'Tests'
}

{ #category : #running }
{ #category : 'running' }
AIAstarTest >> setUp [
super setUp.
astar := AIAstar new
]

{ #category : #tests }
{ #category : 'tests' }
AIAstarTest >> testAseBasicCircuit [

|graphType graph |
Expand All @@ -39,7 +41,7 @@ AIAstarTest >> testAseBasicCircuit [
self assert: Float infinity equals: (astar findNode: $a) pathDistance
]

{ #category : #tests }
{ #category : 'tests' }
AIAstarTest >> testAseBasicCircuitBacktrack [

|graphType graph |
Expand Down Expand Up @@ -73,7 +75,7 @@ AIAstarTest >> testAseBasicCircuitBacktrack [
reconstructPath))
]

{ #category : #tests }
{ #category : 'tests' }
AIAstarTest >> testComplexWeightedGraph2 [


Expand All @@ -95,7 +97,7 @@ AIAstarTest >> testComplexWeightedGraph2 [
self assert: (astar findNode: 5) pathDistance equals: 10
]

{ #category : #tests }
{ #category : 'tests' }
AIAstarTest >> testComplexWeightedGraph2BackTracking [

| shortestPath graphType graph |
Expand Down Expand Up @@ -138,7 +140,7 @@ AIAstarTest >> testComplexWeightedGraph2BackTracking [
astar reset
]

{ #category : #tests }
{ #category : 'tests' }
AIAstarTest >> testComplexWeightedGraph3 [

|graphType graph |
Expand All @@ -158,7 +160,7 @@ AIAstarTest >> testComplexWeightedGraph3 [
self assert: (astar findNode: $e) pathDistance equals: 2
]

{ #category : #tests }
{ #category : 'tests' }
AIAstarTest >> testComplexWeightedGraph3Backtracking [

| shortestPath graphType graph |
Expand Down Expand Up @@ -195,7 +197,7 @@ AIAstarTest >> testComplexWeightedGraph3Backtracking [
astar reset
]

{ #category : #tests }
{ #category : 'tests' }
AIAstarTest >> testSimpleWeightedGraph [

|graphType graph |
Expand All @@ -215,7 +217,7 @@ AIAstarTest >> testSimpleWeightedGraph [
self assert: (astar findNode: 5) pathDistance equals: 3
]

{ #category : #tests }
{ #category : 'tests' }
AIAstarTest >> testSimpleWeightedGraphBacktracking [

| shortestPath graphType graph |
Expand Down
20 changes: 11 additions & 9 deletions src/AI-Algorithms-Graph-Tests/AIBFSTest.class.st
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
Class {
#name : #AIBFSTest,
#superclass : #TestCase,
#name : 'AIBFSTest',
#superclass : 'TestCase',
#instVars : [
'bfsp'
],
#category : #'AI-Algorithms-Graph-Tests-Tests'
#category : 'AI-Algorithms-Graph-Tests-Tests',
#package : 'AI-Algorithms-Graph-Tests',
#tag : 'Tests'
}

{ #category : #running }
{ #category : 'running' }
AIBFSTest >> setUp [
super setUp.
bfsp := AIBFS new
]

{ #category : #tests }
{ #category : 'tests' }
AIBFSTest >> testAseGraph [

|graph graphType|
Expand All @@ -32,7 +34,7 @@ AIBFSTest >> testAseGraph [
self assert: (#() hasEqualElements: (bfsp runFrom: $f to: $a))
]

{ #category : #tests }
{ #category : 'tests' }
AIBFSTest >> testAseSccGraph [

|graph graphType|
Expand All @@ -45,7 +47,7 @@ AIBFSTest >> testAseSccGraph [
self assert: (#( $a $b $d ) hasEqualElements: (bfsp runFrom: $a to: $d))
]

{ #category : #tests }
{ #category : 'tests' }
AIBFSTest >> testComplexUndirectedGraph [

|graph graphType|
Expand All @@ -62,7 +64,7 @@ AIBFSTest >> testComplexUndirectedGraph [
self assert: (#( 4 3 2 12 9 ) hasEqualElements: (bfsp runFrom: 4 to: 9))
]

{ #category : #tests }
{ #category : 'tests' }
AIBFSTest >> testSimpleGraph [

|graph graphType|
Expand All @@ -74,7 +76,7 @@ AIBFSTest >> testSimpleGraph [
self assert: (#( $d $c ) hasEqualElements: (bfsp runFrom: $d to: $c))
]

{ #category : #tests }
{ #category : 'tests' }
AIBFSTest >> testWithoutCyclesComplexGraph [

|graph graphType|
Expand Down
18 changes: 10 additions & 8 deletions src/AI-Algorithms-Graph-Tests/AIBellmanFordTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@
An AIBellmanFordTest is a test class for testing the behavior of AIBellmanFord
"
Class {
#name : #AIBellmanFordTest,
#superclass : #TestCase,
#name : 'AIBellmanFordTest',
#superclass : 'TestCase',
#instVars : [
'bellmanFord'
],
#category : #'AI-Algorithms-Graph-Tests-Shortest path'
#category : 'AI-Algorithms-Graph-Tests-Shortest path',
#package : 'AI-Algorithms-Graph-Tests',
#tag : 'Shortest path'
}

{ #category : #running }
{ #category : 'running' }
AIBellmanFordTest >> setUp [
super setUp.
bellmanFord := AIBellmanFord new
]

{ #category : #tests }
{ #category : 'tests' }
AIBellmanFordTest >> testNegativeUnconnectedWeightedGraph [

|graphType graph |
Expand Down Expand Up @@ -44,7 +46,7 @@ AIBellmanFordTest >> testNegativeUnconnectedWeightedGraph [
self assert: (bellmanFord findNode: 9) pathDistance equals: Float negativeInfinity
]

{ #category : #tests }
{ #category : 'tests' }
AIBellmanFordTest >> testNegativeWeightedGraph [

|graphType graph |
Expand All @@ -71,7 +73,7 @@ AIBellmanFordTest >> testNegativeWeightedGraph [
self assert: (bellmanFord findNode: 9) pathDistance equals: Float negativeInfinity
]

{ #category : #tests }
{ #category : 'tests' }
AIBellmanFordTest >> testNegativeWeightedGraph2 [

|graphType graph |
Expand Down Expand Up @@ -99,7 +101,7 @@ AIBellmanFordTest >> testNegativeWeightedGraph2 [
self assert: (bellmanFord findNode: 9) pathDistance equals: Float negativeInfinity
]

{ #category : #tests }
{ #category : 'tests' }
AIBellmanFordTest >> testNegativeWeightedGraphReconstrucPath [

|graphType graph |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ Graph Class:
4. Complex Graphs
"
Class {
#name : #AICyclicNonWeightedComplexFixture,
#superclass : #Object,
#name : 'AICyclicNonWeightedComplexFixture',
#superclass : 'Object',
#instVars : [
'complexCycleGraph',
'complexCycleGraph2',
'complexUndirectedGraph',
'stronglyConnectedGraph',
'stronglyConnectedGraphWithObjects'
],
#category : #'AI-Algorithms-Graph-Tests-Fixture'
#category : 'AI-Algorithms-Graph-Tests-Fixture',
#package : 'AI-Algorithms-Graph-Tests',
#tag : 'Fixture'
}

{ #category : #fixtures }
{ #category : 'fixtures' }
AICyclicNonWeightedComplexFixture >> complexCycleGraph [

"https://i.imgur.com/4trPCcb.jpeg"
Expand All @@ -35,7 +37,7 @@ AICyclicNonWeightedComplexFixture >> complexCycleGraph [
^graph
]

{ #category : #fixtures }
{ #category : 'fixtures' }
AICyclicNonWeightedComplexFixture >> complexCycleGraph2 [
| nodes edges graph|
nodes := $a to: $i.
Expand All @@ -52,7 +54,7 @@ AICyclicNonWeightedComplexFixture >> complexCycleGraph2 [
^graph
]

{ #category : #fixtures }
{ #category : 'fixtures' }
AICyclicNonWeightedComplexFixture >> complexUndirectedGraph [

"https://i.imgur.com/qK2zsYb.png"
Expand All @@ -72,7 +74,7 @@ AICyclicNonWeightedComplexFixture >> complexUndirectedGraph [
^graph
]

{ #category : #initialization }
{ #category : 'initialization' }
AICyclicNonWeightedComplexFixture >> initialize [
|persons|
super initialize .
Expand All @@ -84,7 +86,7 @@ AICyclicNonWeightedComplexFixture >> initialize [
stronglyConnectedGraphWithObjects := self stronglyConnectedGraph: persons.
]

{ #category : #fixtures }
{ #category : 'fixtures' }
AICyclicNonWeightedComplexFixture >> stronglyConnectedGraph [

"This a graph for 4 strongly connected components "
Expand All @@ -102,7 +104,7 @@ AICyclicNonWeightedComplexFixture >> stronglyConnectedGraph [
^graph
]

{ #category : #fixtures }
{ #category : 'fixtures' }
AICyclicNonWeightedComplexFixture >> stronglyConnectedGraph: objects [

"This is the exact same graph as #stronglyConnectedGraph: but using a custom object"
Expand All @@ -122,7 +124,7 @@ AICyclicNonWeightedComplexFixture >> stronglyConnectedGraph: objects [
^graph
]

{ #category : #fixtures }
{ #category : 'fixtures' }
AICyclicNonWeightedComplexFixture >> stronglyConnectedGraph: graphBuilder withObjects: objects [

"This is the exact same graph as #stronglyConnectedGraph: but using a custom object"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Graph Class:
4. Simple Graphs
"
Class {
#name : #AICyclicNonWeightedSimpleFixture,
#superclass : #Object,
#name : 'AICyclicNonWeightedSimpleFixture',
#superclass : 'Object',
#instVars : [
'aseCircuitGraph',
'aseSccGraph',
Expand All @@ -17,10 +17,12 @@ Class {
'nestedCycleGraph',
'simpleGraphForHits'
],
#category : #'AI-Algorithms-Graph-Tests-Fixture'
#category : 'AI-Algorithms-Graph-Tests-Fixture',
#package : 'AI-Algorithms-Graph-Tests',
#tag : 'Fixture'
}

{ #category : #fixtures }
{ #category : 'fixtures' }
AICyclicNonWeightedSimpleFixture >> aseCircuitGraph [

"https://i.imgur.com/t1S6dG4.jpeg"
Expand All @@ -37,7 +39,7 @@ AICyclicNonWeightedSimpleFixture >> aseCircuitGraph [
^graph
]

{ #category : #fixtures }
{ #category : 'fixtures' }
AICyclicNonWeightedSimpleFixture >> aseSccGraph [

| nodes edges graph|
Expand All @@ -50,7 +52,7 @@ AICyclicNonWeightedSimpleFixture >> aseSccGraph [
^graph
]

{ #category : #fixtures }
{ #category : 'fixtures' }
AICyclicNonWeightedSimpleFixture >> cycleGraph [

"https://i.imgur.com/MNtwA56.jpeg"
Expand All @@ -65,7 +67,7 @@ AICyclicNonWeightedSimpleFixture >> cycleGraph [
^graph
]

{ #category : #fixtures }
{ #category : 'fixtures' }
AICyclicNonWeightedSimpleFixture >> dependencyGraph [

| nodes edges graph|
Expand All @@ -80,7 +82,7 @@ AICyclicNonWeightedSimpleFixture >> dependencyGraph [
^graph
]

{ #category : #initialization }
{ #category : 'initialization' }
AICyclicNonWeightedSimpleFixture >> initialize [
super initialize .
aseCircuitGraph := self aseCircuitGraph .
Expand All @@ -92,7 +94,7 @@ AICyclicNonWeightedSimpleFixture >> initialize [
simpleGraphForHits := self simpleGraphForHits .
]

{ #category : #fixtures }
{ #category : 'fixtures' }
AICyclicNonWeightedSimpleFixture >> moduleGraph [

| nodes edges graph |
Expand All @@ -114,7 +116,7 @@ AICyclicNonWeightedSimpleFixture >> moduleGraph [
^graph
]

{ #category : #fixtures }
{ #category : 'fixtures' }
AICyclicNonWeightedSimpleFixture >> nestedCycleGraph [

"https://i.imgur.com/6lk0pmR.jpeg"
Expand All @@ -131,7 +133,7 @@ AICyclicNonWeightedSimpleFixture >> nestedCycleGraph [
^graph
]

{ #category : #fixtures }
{ #category : 'fixtures' }
AICyclicNonWeightedSimpleFixture >> simpleGraphForHits [

"https://i.imgur.com/FvqrFbf.png"
Expand Down
Loading

0 comments on commit 8b9f916

Please sign in to comment.