Gremlin query to get all interconnected vertex value in javascript - javascript

Can any one help me to figure out how to fetch content of all vertex which are connected each other in javascript , I need all the values of all vertex which are connected
For example in below diagram I have a business vertex and there are two outgoing edges from business , what I need is all the contents of business vertex and video and image vertex
graph look like this

Gremlin provides a variety of ways that you might be able to handle this as your description of the desired results was a bit vague. However you will want to use a combination of traversing steps (out() step), filtering steps (has()/hasLabel()) combined with the path() step to get the list of vertices and then return the data using elementMap(). I have put a demonstration of this here:
https://gremlify.com/a78ox51u9os/1

Related

Isolate Country/Region from TopoJSON

I am using the natural earth 10m files to reduce, simplify, and quantize them into TopoJSON. However, for my use case, I'm attempting to store the data on the server and request a country or region I am currently interested in to display with d3. Because of this I need to keep my file size fairly small.
I was able to write some hacky code to strip out the region geometry data and arcs from the full TopoJSON file and serve that at a reasonably small size. Unfortunately, I've come to realize that doing a mesh on this does not give me any results. If, however, I do not reindex all of the arcs and instead just inject empty arrays into the arc positions I don't need, mesh works fine.
Basically, my question is, is there a way for me to strip out a specific country or region from a large TopoJSON file? I don't mean just the geometry object since that's easy enough to do, but also reduce the main arcs array to only include what is needed. I'm struggling to find a clean way to do this.
Thanks!

Reuse image in three.js textures

I'm trying to load with three.js the same image in a large number (~ 1000) of bidimensional shapes but with different offsets in every shape.
I've taken this demo from the official website and customized it into this other demo, with all my shapes and a random background texture.
The problem is that if I clone the texture once per shape the page eats a lot of RAM and it ends up crashing.
You can see this in action by going in the javascript and changing the comments in the addShape function (you'll find the instructions in the code).
I've done some research and found some results, like this open issue or this older question where it's recommended to clone the texture; anyway nothing seems to work in my example.
Am I doing something wrong? It's changed something since these last posts about this problem?
Maybe I´m misunderstanding the problem, but why don´t you change the UV coordinates of the individual shapes to align the texture and use just one texture?
From documentation:
Geometry.faceVertexUvs
Array of face UV layers, used for mapping textures onto the geometry.
Each UV layer is an array of UVs matching the order and number of
vertices in faces.
To signal an update in this array, Geometry.uvsNeedUpdate needs to be
set to true.

build complete graph with n vertices using javascript

I need to implement an algorithm which involves building a complete graph using JavaScript functions as first step.
Are there any fast ways (like libraries or build-in functions I can use? Or may I get some suggestions on how to set up the data-structures efficiently and easily using JavaScript?
Further more, given n vertices, after building a complete graph,
for each iteration:
Try vertex-cover like thing,(if there'are odd number of vertices, just leave the last one alone) and then store the pairs of vertices for each edge in the vertex cover, and then remove the edges involved in that vertex cover, and then sort the vertices by orders that has biggest number of edges remaining to be removed
and then looping doing so, until no edges been left in the graph.
Thank you very much.

Render large matrix (1000*1000) in Javascript

I need to display a large matrix within our web-based application. The matrix dimensions are approx. 1000*1000 and each cell is either filled or not.
Basically, it should look like this (much larger and without the colors):
http://mbostock.github.com/protovis/ex/matrix.html
I need basic interaction, such as zooming and clicking on a cell. The matrix is likely to to be a sparse matrix.
I tried Protovis but rendering takes forever if the matrix is larger than 80*80.
What Javascript library might be suitable for this task?
I would use an HTML5 Canvas for fast drawing. (This super-simple demo renders in a few seconds on my computer.) If you want to zoom in, you can see this answer.
In order to display a million items to a user, each element would probably have to be the size of a single pixel.
I'd just use a canvas.
You could try the JavaScript library clustergrammer.js (see https://github.com/cornhundred/clustergrammer.js). It uses D3.js to make interactive (zoomable, reorderable, filterable, etc) visualizations. It can handle on the order of 100,000 data points, but if you matrix is sparse enough then you can render large matrices.
Here's an example of clustergrammer.js being used to visualize a 6000x230 matrix http://amp.pharm.mssm.edu/clustergrammer/viz/568affd5b6541b84f3a68234

D3.js and PHP: Draw graph limited by input constraints

I have a list of constraints that are input by user in a HTML form and passed to a PHP page, as in this picture:
Each constraint is an array, containg all the x1,x2... values and the type of constraint (less than, equal or greater than), and the value of the right side after the constraint type.
How could I draw a graph based on those constraints with PHP, like the one in this picture:
That is, I'd build a code to solve the equations separately and draw the solutions (results) as segments in the graph, creating a region limited by the segments, as shown in the second picture.
Is there a way to implement there with D3.js? I'm new with JavaScript but it seems this library is useful for it, but I'm totally lost, since I'm only finding things that are really complex, like plotting scatter plots with input data that contains hundreds of elements. Any help?

Categories