Skip to content

Methods that take vertex names should also take VertexNameSpec #82

@moaxcp

Description

@moaxcp

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions