I am trying to fetch edge property value between two vertices. E.g. A-->B
A and B are two vertices and it has edge with property(name).
My code looks like:
graph.V().hasLabel(A).outE().value("name").headOption()
It gives me the property value for name.
In a given two vertices, i am getting None as output
graph.traversal().V().hasLabel(A).outE("test").outV().hasLabel(B).properties("name").headOption()
'test' - Edge Label
'name' - Edge property
Any idea what is wrong with my query.
Apologies for not being able to answer this in your comments on the previous question you asked. I think what you are looking for is:
graph.traversal().V()
.hasLabel("A").outE("test").as("x").otherV()
.hasLabel("B").select("x").properties("name");
If you just want the values of the properties on the edge you can do the following:
graph.traversal().V()
.hasLabel("A").outE("test").as("x").otherV()
.hasLabel("B").select("x").values("name");
Side Note (Why is your original traversal wrong): Your original traversal:
graph.traversal().V().hasLabel(A).outE("test").outV().hasLabel(B).properties("name").headOption()
is doing the following:
Get all vertices with the label "A"
From those vertices follow the outward going edges which have the label "test" to vertices which have the label "B"
Then get the property "name" from those vertices
You are actually asking for the properties on the vertex.
Related
I think i have a difficult problem right here..
I want to able to get the surfaces of f.e. the orange object in this three.js example https://threejs.org/examples/?q=stl#webgl_loader_stl
i want to click with the mouse, find the correct surface, which should then be highlighted, so i make sure this was the surface i want.
(i already implemented raycaster successfully, so thats not an issue)
The intersectObject method returns an array of intersections, each of which has face property. The face contains vertex indices.
For STL files containing multiple solids, each solid is assigned to a different group, and the groups are available in the geometry object that is returned from STLLoader. Each group is defined by a range of vertex indices.
So, I think you can correlate the vertex indices returned from the raycaster with the vertex indices in the geometry groups.
I have to get the vertices having some label (which will return me multiple vertices) and get max value from all outgoing Edges of the vertices.
My query looks like this
g.V().hasLabel(id).outE().values("range").max().path().headOption().get
it returns something [100].
Is there is better way to do this. It returns list i need only the value
I'm using Tinkerpop 3.0.1 (Titan 1.0.0), and I try to list all edges for a vertex, sorted by degree of the node on the other end of the edge.
I tried:
g.V(1482896).bothE().order().by(otherV().bothE().count(), decr)
I get the following error from Titan:
The path history of the traverser does not contain a previous vertex: [e[1d2m8u-1d70ts-b2t-vs7k][82628848-DIRECTED->1482896]]
The strange thing is, there is a previous vertex in the path (namely vertex #1482896. I'm confused on how to solve this one.
Answering my own question, after playing around with this, I found a workaround:
g.V(123).bothE().as('edges')
.otherV().order().by(bothE().count(), decr)
.select('edges')
This will effectively sort edges adjacent to vertex #123 by highest degree of the node on the other end of the edge.
currently the algorithm returns only the vertices , but how to get the edges that it chose ? as there can be multiple edges between the vertices
I'll have to modify current function. Search source code 'OSQLFunctionDijkstra.java' for existing function and inside 'getDistance' method it should be easy to print 'Edge' information.
I'm trying to figure out how to loop over verticies within a container and adding edges between the current vertice in the loop and a given vertice.
This is what I have so far:
This gives me an array of all vertice id's within the given container:
v=g.V('containerName','MyContainer').outE.inV.id
result:
{"results":[12,320004,280004,240004,200004,160004,120004,80004,40004],"success":true,"version":"2.4.0","queryTime":35.089565}
Now I want to loop/iterate over all the id's in this array, get the vertice of the id and add an edge between a given vertice and the current vertice in the loop.
Anyone that knows how this can be done?
You can make a sideEffect that adds the new edges.
With the toy tinker graph:
g = TinkerGraphFactory.createTinkerGraph()
let's assume you want to link peter to all neighbors of marko (out only)
givenVertex = g.V('name','peter').next()
g.V('name','marko').out.sideEffect{g.addEdge(givenVertex,it, 'yourLabel')}
verify result:
g.V('name','peter').out.name
==>lop // lop appears twice because edge peter -> lop was present previous to operation
==>lop
==>vadas
==>josh