-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added coverage and validations #11
Conversation
Pull Request Test Coverage Report for Build 39
💛 - Coveralls |
source/Mole/GraphBuilder.class.st
Outdated
@@ -1,32 +1,116 @@ | |||
" | |||
I'm an abstract class aiding with the creation of graphs. | |||
I'm a builder of directed graphs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment needs to be updated
|
||
{ #category : #building } | ||
GraphBuilder >> buildUndirected [ | ||
|
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
source/Mole/GraphBuilder.class.st
Outdated
GraphBuilder >> connect: aSourceVertex to: aTargetVertex labeled: aLabel [ | ||
|
||
"In graph theory, the edge label can be any element attached to it. It is possible to label an edge with a name, a color, a weight or even a function." | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say even an object instead of a function ;)
source/Mole/GraphBuilder.class.st
Outdated
|
||
^ self subclassResponsibility | ||
^ UndirectedEdge | ||
relating: (Bag with: edgeArray first with: edgeArray last) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edgeArray asBag
?
{ #category : #private } | ||
UndirectedEdge >> isLabeledLike: anEdge [ | ||
|
||
^ self |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
source/Mole/GraphBuilder.class.st
Outdated
self | ||
addVertex: aSourceVertex; | ||
addVertex: aTargetVertex. | ||
labelByEdgeArray at: (Array with: aSourceVertex with: aTargetVertex) put: aLabelOptional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not { aSourceVertex. aTargetVertex }
?
{ #category : #testing } | ||
Edge >> isDirected [ | ||
|
||
^ self subclassResponsibility |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
source/Mole-Tests/GraphTest.class.st
Outdated
ifUnlabeled: [ self fail ] ]. | ||
self assertCollection: labelByEdge keys hasSameElements: aDictionary keys. | ||
aDictionary | ||
keysAndValuesDo: [ :edgeString :weight | self assert: (labelByEdge at: edgeString) equals: weight ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of test can be non-deterministic because the string you create in the match dictionary are fixed, and the other ones are generated here. The endpoints in the undirected edge ends up in a Bag or Set, so the order can be different, then the string also can be different.
stream := WriteStream on: String new. | ||
edgeFunction := [ :source :target | | ||
stream | ||
nextPutAll: ('From <1s> to <2s' expandMacrosWith: source with: target); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'From <1s> to <2s'
is missing a >
no?
This comment has been minimized.
This comment has been minimized.
source/Mole-Tests/GraphTest.class.st
Outdated
@@ -23,11 +23,10 @@ GraphTest >> assertEdgesIncidentTo: aVertex in: aGraph match: aDictionary [ | |||
edges | |||
do: [ :edge | | |||
edge | |||
withLabelDo: [ :label | labelByEdge at: edge asString put: label ] | |||
withLabelDo: [ :label | labelByEdge at: edge endpoints asSortedCollection asArray asString put: label ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do edge endpoints sorted asString
No description provided.