I am trying to get all the nodes present on a line element with a given physical name in gmesh - gmsh

I am using gmesh to mesh a square domain.I am giving physical names to the line elements on the boundary of the square.Suppose I give a physical name "l" to the left edge of square and a physical name "rb" to the bottom half of the right edge.
Now as I mesh my domain I want to get all the nodes present on the edges with physical name "l" and all the nodes present on the edges with physical name "rb".

Related

Teleport command in Minecraft data pack is ignoring parameters

I have this command that's supposed to teleport players when they reach a specific point on the x axis (regardless of y or z), for some reason it teleports everyone regardless of their position on the x axis
Here's the command - execute at #p[x=-5371] run tp #p[x=-5371] 5365 ~ ~
It's running on a custom data pack as a loop for each tick
It doesn't work like that. You cannot use x= alone in a selector, (x= and dx= must be used tgt; whereas dx is known as the volume selector). Also, you are scanning for the nearest player only and I would suggest for you to use #a which perform the task for all players.
To further elaborate, the volume selector takes resemblance to how you use the fill command, where you will enter the coordinates of the starting point and ending point respectively and the game will calculate the volume and the blocks affected depending on the points you entered, allowing you to fill an entire space with blocks of whatever kind. Similarly, working with the volume selector requires you to fill in 2 parameters, the starting coordinates (x=,y=,z=)
and the coordinate displacements (dx=,dy=,dz=).
Suppose starting coordinates (x, y, z)
Then ending coordinates = (x+dx, y+dy, z+dz)
This allows the game to draft a volume (block region) and evaluate the player position to see if it matches the volume.
An example:
To test for players at point (x=64, y=64, z=64) use the command
execute as #a[x=64,dx=0,y=64,dy=0,z=64,dz=0] run say DetectedPlayer
This draws a block region of 1x1 at point (64, 64, 64) and if the feet coordinate of a player lands in its proximity the player would say in chat "DetectedPlayer"
Albeit I really am not sure if you can have an infinitely extending volume of block region.
I interpret your question as how to set a border for players. In that case I recommend you to use /worldborder which is way more user friendly and conventional```
Here is the page you are looking for if you are hell bent on using the volume selector
https://minecraft.fandom.com/wiki/Target_selectors

How would I find all paths between two nodes using cytoscape.js?

I have a telecommunications mesh network graph where there are multiple path between multiple nodes.
I want to be able to select 2 nodes and highlight all inter connected nodes and edges that make up the paths between them.
How would you recommend I tackle this?
I've tried using aStar, then removing the nodes and edges and reiterating, however some paths share edges so that didn't work.
To get all of the paths between two nodes in Cytoscape.js you can use the following:
function findPaths(src,dest) {
let successors = src.successors();
let predecessors = dest.predecessors();
return successors.intersection(predecessors);
}
This takes all of the nodes and edges from src and keeps only those that are also in the set of those leading to dest.
It does not enumerate the paths - it is just the full set of nodes and edges in the paths.
To actually enumerate all the individual possible paths (it can be a large number if you're dealing with a complex graph) you would do a depth first recursion on the results of this function. Each time dest is visited, you would display the path that led to the visit.

Gremlin: Add an edge and drop an edge in single gremlin query

how to add an edge and dropping an edge to same vertex type in single gremlin query.
say we have two types of vertex types A --is--> B now i have vertex which is connected to some other vertex of B.
I want to update the A's vertex to some other vertex of B.
currently, i am dropping the current B vertex and then adding the new vertex .
You can do it in one traversal using a sideEffect():
gremlin> g.V().has('person','name','marko').as('m').
......1> outE('knows').
......2> filter(inV().has('person','name','vadas')).
......3> sideEffect(drop()).
......4> V().has('person','name','peter').
......5> addE('knows').from('m')
==>e[13][1-knows->6]
At line 1 we basically identify the edge we want to get rid of (i.e. a "knows" edge from "marko" to "vadas") and we drop() that on line 3. At line 4 we lookup the vertex to whom we wish to connect "marko" to now and then add the edge at line 5.

How to find the exact points that an edge connects in jgraphx?

For an edge in jgraphx which has its geometry set to relative, there are no points provided as they are derived from the source and target for the edge.
However, the points found there are the top left corner of the objects: what I would like to know is if there is a way to get the exact points in which the edge connects to the source and target vertex rather than just the position or center point of the object.
Try graph.getView().getPerimeterPoint(mxCellState, mxPoint...)
Provide as cell state your local cell (mxGraphView.getState(myLocalCell)) and as point the distant center point of your other cell linked by the edge (you may compute it from its geometry X, Y, Width and Height).
An jGraphx can be exported to svg format. Maybe the drawCell() in the com.mxgraph.canvas.mxSvgCanvas can help you out. It is the case when shape.equals(mxConstants.SHAPE_LINE) and how the M and L commands are being calculated.

connect line between two boxes avoiding passing others

I have several boxes (x,y,width,height) randomly scattered around, and some of them need to be linked from point (x1,y1) in box1 to point (x2,y2) in box2 by drawing a line. I am trying to figure a way to make such line avoid passing through any other boxes (other than box1 and box2) by drawing several straight interconnected lines to go around any box in the way (if it is not possible to go with one straight line). The problem is that I don't know an algorithm for such thing (let alone having a technical/common name for it). Would appreciate any help in the form of algorithm or expressed ideas.
Thanks
Assuming that the lines can't be diagonal, here's one simple way. It's based on BFS and will also find the shortest line connecting the points:
Just create a graph, containing one vertex for each point (x, y) and for each point the edges:
((x,y),(x+1,y)) ((x,y),(x-1,y)) ((x,y),(x,y+1)) ((x,y),(x,y-1))
But each of this edges must be present only if it doesn't overlap a box.
Now just do a plain BFS from point (x1,y1) to (x2,y2)
It's really easy to obtain also diagonal lines the same way but you will need 8 edges for each vertex, that are, in addition to the previouses 4:
((x,y),(x-1,y+1)) ((x,y),(x-1,y-1)) ((x,y),(x+1,y-1)) ((x,y),(x+1,y+1))
Still, each edge must be present only if it doesn't overlap a box.
EDIT
If you can't consider space divided into a grid, here's another possibility, it won't give you the very shortest path, though.
Create a graph, in which each box is a vertex and has an edge to any other box that can be reached without the line to overlap a third box. Now find the shortet path using dijkstra between box1 and box2 containing the two points.
Now consider each box to have a small countour that doesn't overlap any other box. This way you can link the entering and the exiting point of each box in the path found through dijistra, passing through the countour.
Put all (x,y) coords of the corners of the boxes in a set V
Add the start- and end coordinates to V.
Create a set of edges E connecting each corner that does not cross any box-side (except for the diagonals in the boxes).
How to check if a line crosses a box side can be done with this algorithm
Now use a path-finding algorithm of your choice, to find a path in the graph (V, E).
If you need a simple algorithm that finds the shortest path, just go with a BFS.
(This will produce a path that goes along the sides of some boxes. If this is undesirable, you could in step 1 put the points at some distance delta from the actual corners.)
If the edges may not be diagonal:
Create a large grid of lines that goes between the boxes.
Throw away the grid-edges that cross a box-side.
Find a path in the grid using a path-finding algorithm of your choice.