-
Notifications
You must be signed in to change notification settings - Fork 6
Description
VertexNameSpec
A new object that simply defines the name of a Vertex. Graph.propertyMissing should be changed to return VertexNameSpec instead of VertexSpec. This will eliminate the need for single quotes around vertex names within the dsl.
Examples
rename methods in edge closure
graph {
edge(A, B) {
renameOne 'C'
}
}
Could be changed to:
graph {
edge(A, B) {
renameOne C
}
}
'C' could be replaced with C. Since C is not a property of Graph propertyMissing will be called and return a new VertexNameSpec.
connectsTo and connectsFrom
graph {
vertex A {
connectsTo 'C'
connectsFrom 'B'
}
}
could become
graph {
vertex A {
connectsTo C
connectsFrom B
}
}
root in traversal methods
graph {
breadthFirstTraversal {
root = 'A'
visit { vertex ->
println "bft $vertex.name"
}
}
}
could become
graph {
breadthFirstTraversal {
root A
visit { vertex ->
println "bft $vertex.name"
}
}
}
Strings
Strings will still need to be supported for method calls and properties outside of the dsl. For example BreadthFirstTraversal has the property root. This is a String and will remain a String. A new method should be added to support setting that property using a VertexNameSpec.
apply VertexNameSpec to the Graph
Any VertexNameSpec passed to these methods need to be treated as a normal VertexSpec. This means they need to be applied to the graph not just used as a reference to a Vertex.
connectsTo and connectsFrom should accept a VertexSpec
This will allow more nested strucures when defining a graph.
graph {
vertex A {
connectsTo B {
connectsTo C {
connectsTo D
}
}
}
}
update readme
All examples in the readme that use the graph {...} entry point should use this feature.