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
Related
So, I'm using a boolean operator to get the intersection of a bunch of pieces and a wall. Most pieces work fine but occasionally the intersection isn't perfect and you get these vertices that aren't connected to the rest of the mesh and this results in the mesh collider being incorrect, as seen in this picture.
My question is whether there is a way to detect these 'island' or 'lone' vertices.
I can provide additional images, code, or such if needed.
Thanks for any help! Ps. first question here so please be patient with me :)
In the end, I kind of solved it by finding all connected vertices starting from a single vertex.
I started by picking the first triangle and adding it's vertices to a list of connected vertices. Then I go through the list of triangles comparing the position of their vertices to the list of connected vertices. If the triangle has a vertex with a position corresponding to a position in the list of connected vertices I add the entire triangle to the list. That's one iteration and I repeat this until all connected triangles are already in the list. If the connected triangle list is more than half of all triangles then I remove all other triangles, otherwise, I remove the current list of connected triangles. After that, I clear the vertices that aren't in a triangle like Leo Bartkus suggested.
It's extremely slow and it assumes there are only 2 separate islands or that you started on the biggest island, but it worked most of the time and was more for learning purposes anyways.
Thank's for the help!
I have been trying to reconcile the coordinates returned by the matching geometry and the nodes in each leg when doing a match call with annotations=true overview=full and geometries=geojson.
I would like to understand how to align the node IDs with the lat/lon of a coordinate geometry.
My understanding is that there is a 1:1 mapping between the coordinates and the nodes in the legs.
I have tried "simplifying" the node IDs returned in the annotations by doing the following:
Append the first leg annotations to your result.
Repeat the following for each extra leg:
a. Trim the first two nodes from the start of the next leg annotation to append
b. Append the trimmed leg annotation to your result
Then I remove the locations returned by the waypoints from the coordinates in the geometry. After, I try to line up the simplified node IDs with the remaining coordinates. However, this method end up with a couple (and sometimes a few) extra points which we aren't able to explain or figure out how to filter out.
Anyone have a more reliable method for solving this? Appreciate all the help. Thanks!
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 am making a script which can generate multiple objects in Pyglet. In this example (see link below) there are two pyramids in 3d space, but every triangle is recalculated in every frame. My aim is to make a swarm with a large number of pyramids flying around, but i cant seem to figure out how to implement vertex lists in a batch. (assuming this is the fastest way to do it).
Do they need to be indexed for example? (batch.add_indexed(...) )
A standard seems to be:
batch1 = pyglet.graphics.Batch()
then add vertices to batch1. and finally:
def on_draw():
batch1.draw()
So how to do the intermediate step, where pyramids are added to vertex lists? A final question: when would you suggest to use multiple batches?
Thank you!
apfz
http://www.2shared.com/file/iXq7AOvg/pyramid_move.html
Just have a look at pyglet.sprite.Sprite._create_vertex_list for inspiration. There, the vertices for simple sprites (QUADS) are generated and added to a batch.
def _create_vertex_list(self):
if self._subpixel:
vertex_format = 'v2f/%s' % self._usage
else:
vertex_format = 'v2i/%s' % self._usage
if self._batch is None:
self._vertex_list = graphics.vertex_list(4,
vertex_format,
'c4B', ('t3f', self._texture.tex_coords))
else:
self._vertex_list = self._batch.add(4, GL_QUADS, self._group,
vertex_format,
'c4B', ('t3f', self._texture.tex_coords))
self._update_position()
self._update_color()
So the required function is Batch.add(vertex_list). Your vertices should only be recalculated if your pyramid changes it's position and not at every draw call. Instead of v2f you need to use v3f for 3D-coordinates and of course you need GL_TRIANGLES instead of GL_QUADS. Here is an example of a torus rendered with pyglet.