-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from HPI-SWA-Teaching/final-graph
Add new graph Algorithm
- Loading branch information
Showing
10 changed files
with
72 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
as yet unclassified | ||
cellSize | ||
|
||
^ 30 |
47 changes: 41 additions & 6 deletions
47
GANA-UI.package/GanaGraphMorph.class/instance/initializeSubmorphs.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,47 @@ | ||
as yet unclassified | ||
initializeSubmorphs | ||
|
||
| circleSize vertices commitList | | ||
| circleSize vertices commitList "pq" heapSortBlock childDict infoDict positionDict lastCommitPerColumn | | ||
self flag: #refactor. "Create a class for this?" | ||
|
||
heapSortBlock := [ :a :b | (a metadata at: #timestamp) > (b metadata at: #timestamp) ]. "Potentially dangerous when using multiple time zones" | ||
"pq := Heap sortBlock: heapSortBlock. - We don't need a priority queue anymore as we get a complete commitlist already sorted by timestamps" | ||
childDict := Dictionary new. | ||
infoDict := Dictionary new. | ||
positionDict := Dictionary new. | ||
lastCommitPerColumn := OrderedCollection new. | ||
circleSize := self nodeSize asPoint. | ||
vertices := OrderedCollection new. | ||
commitList := self graphSource. | ||
1 to: commitList size do: [ :row || p | | ||
p := self positionNodeAt: row For: (commitList at: row). | ||
vertices add: p]. | ||
vertices := (vertices * circleSize) + (self nodeSize / 2) asPoint. | ||
self addMorphBack: (self defaultLine setVertices: vertices asArray; yourself). | ||
1 to: commitList size do: [ :rowIndex || commit | | ||
commit := (commitList at: rowIndex) version. | ||
1 to: (commit parents size) do: [ :count | | parent | "What if it has no parent?" | ||
parent := (commit parents at: count). | ||
childDict at: parent ifPresent: [:childCollection | childDict at: parent put: (childCollection add: commit; yourself)] ifAbsentPut: [ | ||
(Heap sortBlock: heapSortBlock) | ||
add: commit; | ||
yourself.] | ||
]. | ||
childDict at: commit ifPresent: [:pqchildren | | child childInfo | | ||
child := pqchildren first. | ||
childInfo := infoDict at: child. "Consists of painted Column and potential Successor" | ||
(childInfo size < 2) ifTrue: [positionDict at: commit put: (self positionNodeAt: rowIndex withColumn: (childInfo first)). "We can be sure this exists because if we have children then they already have had to be painted and thus added to this dict" | ||
lastCommitPerColumn at: (childInfo first) put: commit. | ||
infoDict at: child put: (Array with: (childInfo first) with: commit). | ||
infoDict at: commit put: (Array with: (childInfo first)) | ||
|
||
] | ||
ifFalse: [lastCommitPerColumn add: commit. | ||
positionDict at: commit put: (self positionNodeAt: rowIndex withColumn: (lastCommitPerColumn size)). | ||
infoDict at: commit put: (Array with: (lastCommitPerColumn size)). | ||
]. | ||
1 to: (pqchildren size) do: [ :count | | ||
self positionLineBetween: (positionDict at: (pqchildren removeFirst)) And: (positionDict at: commit). | ||
]. | ||
] | ||
ifAbsent: [ "This should only be called for children-less commits, eg branch pointer" | ||
lastCommitPerColumn add: commit. | ||
positionDict at: commit put: (self positionNodeAt: rowIndex withColumn: (lastCommitPerColumn size)). | ||
infoDict at: commit put: (Array with: (lastCommitPerColumn size)) | ||
]. | ||
]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
as yet unclassified | ||
nodeSize | ||
|
||
^ 14 | ||
^ 24 |
8 changes: 8 additions & 0 deletions
8
GANA-UI.package/GanaGraphMorph.class/instance/positionLineBetween.And..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
as yet unclassified | ||
positionLineBetween: child And: parent | ||
|
||
| start end | | ||
start := self cellSize asPoint * child + (self cellSize / 2 asPoint). | ||
end := self cellSize asPoint * parent + (self cellSize / 2 asPoint). | ||
|
||
self addMorphBack:( LineMorph from: start to: end color: (Color black) width: 2). |
10 changes: 0 additions & 10 deletions
10
GANA-UI.package/GanaGraphMorph.class/instance/positionNodeAt.For..st
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
GANA-UI.package/GanaGraphMorph.class/instance/positionNodeAt.withColumn..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
as yet unclassified | ||
positionNodeAt: row withColumn: column | ||
|
||
| p | | ||
p := column@row - (1@1). | ||
self addMorph:( self defaultNode | ||
position: (self cellSize asPoint * p) + (self cellSize - self nodeSize / 2) asPoint; | ||
yourself). | ||
^ p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters