Skip to content

Commit

Permalink
Merge pull request #36 from astares/34-2-Cleanup-AI-Algorithms-Graph-…
Browse files Browse the repository at this point in the history
…package-contains-untagged-classes

Cleanup: "AI-Algorithms-Graph" package contains untagged classes
  • Loading branch information
jecisc authored Nov 22, 2023
2 parents 876fd9c + 5558fd1 commit 3029f27
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
38 changes: 20 additions & 18 deletions src/AI-Algorithms-Graph/AIDinic.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,20 @@ value:= dinic run.
value.
"
Class {
#name : #AIDinic,
#superclass : #AIGraphAlgorithm,
#name : 'AIDinic',
#superclass : 'AIGraphAlgorithm',
#instVars : [
'adjList',
'queue',
'start',
'sink'
],
#category : #'AI-Algorithms-Graph'
#category : 'AI-Algorithms-Graph-Dinic',
#package : 'AI-Algorithms-Graph',
#tag : 'Dinic'
}

{ #category : #configuration }
{ #category : 'configuration' }
AIDinic >> addAdjList [

| arr fromNode |
Expand All @@ -68,13 +70,13 @@ AIDinic >> addAdjList [
arr add: i ]
]

{ #category : #accessing }
{ #category : 'accessing' }
AIDinic >> adjList [

^ adjList
]

{ #category : #backtracking }
{ #category : 'backtracking' }
AIDinic >> bfs [
"This method uses bfs on the residual graph to construct a level graph.
The level graph assigns levels or distances to each node, indicating the shortest path from the source.
Expand All @@ -95,13 +97,13 @@ AIDinic >> bfs [
^ returnBool
]

{ #category : #configuration }
{ #category : 'configuration' }
AIDinic >> currentIndexSetup [

self nodes do: [ :n | n currentIndex: 1 ]
]

{ #category : #backtracking }
{ #category : 'backtracking' }
AIDinic >> dfs: fromNode pushed: p [
"This method uses DFS-style algorithm to find a blocking flow (A blocking flow is a flow that saturates all the edges on the path, preventing any further flow) along the augmenting path.
This performs a series of depth-first searches on the residual graph, exploring the edges with positive residual capacity."
Expand Down Expand Up @@ -136,13 +138,13 @@ This performs a series of depth-first searches on the residual graph, exploring
^ 0
]

{ #category : #configuration }
{ #category : 'configuration' }
AIDinic >> edgeClass [

^ AINetworkFlowEdge
]

{ #category : #'building - graph' }
{ #category : 'building - graph' }
AIDinic >> edges: aCollection from: source to: target capacity: capacityFunction [

| edge edgeRev|
Expand All @@ -153,15 +155,15 @@ AIDinic >> edges: aCollection from: source to: target capacity: capacityFunction
edgeRev ifNotNil: [ edgeRev capacity:0 ].]
]

{ #category : #initialization }
{ #category : 'initialization' }
AIDinic >> initialize [

super initialize.
adjList := Dictionary new.
queue := LinkedList new
]

{ #category : #configuration }
{ #category : 'configuration' }
AIDinic >> initializeBfs [
"This method
- Initialises all the levels and current index of the nodes
Expand All @@ -175,26 +177,26 @@ AIDinic >> initializeBfs [
^ self bfs
]

{ #category : #configuration }
{ #category : 'configuration' }
AIDinic >> levelSetup [

self nodes do: [ :n | n level: -1 ]
]

{ #category : #utilities }
{ #category : 'utilities' }
AIDinic >> minimumValue: firstNumber compare: secondNumber [

firstNumber > secondNumber ifTrue: [ ^ secondNumber ].
^ firstNumber
]

{ #category : #configuration }
{ #category : 'configuration' }
AIDinic >> nodeClass [

^ AIDinicNode
]

{ #category : #utilities }
{ #category : 'utilities' }
AIDinic >> reverseEdge: fromNode to: toNode [

| e |
Expand All @@ -203,7 +205,7 @@ AIDinic >> reverseEdge: fromNode to: toNode [
e to == toNode & (e capacity = 0) ifTrue: [ ^ e ] ]
]

{ #category : #running }
{ #category : 'running' }
AIDinic >> run [

| finalFlow pushed breakLoop |
Expand All @@ -222,7 +224,7 @@ AIDinic >> run [
^ finalFlow
]

{ #category : #initialization }
{ #category : 'initialization' }
AIDinic >> setStartNode: startNode sinkNode: sinkNode [

start := startNode.
Expand Down
5 changes: 3 additions & 2 deletions src/AI-Algorithms-Graph/AIPrim.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ For more, see: https://en.wikipedia.org/wiki/Prim%27s_algorithm
Class {
#name : 'AIPrim',
#superclass : 'AIGraphAlgorithm',
#category : 'AI-Algorithms-Graph',
#package : 'AI-Algorithms-Graph'
#category : 'AI-Algorithms-Graph-Prim',
#package : 'AI-Algorithms-Graph',
#tag : 'Prim'
}

{ #category : 'configuration' }
Expand Down

0 comments on commit 3029f27

Please sign in to comment.