Build graph (network) from vertices defined by an (x,y) position - graph

Is there an efficient way to build a network from a list of vertices that are defined by their (x,y) coordinates?
Algorithms or links to some examples would help.

Related

If i already know the Voronoi vertices points, how can i create a polygon from the list?

I'm trying to create this in Gamemaker. I already know the Voronoi vertices but i'm stuck with how to create polygons for each seed object. I need them to be independent so i can split it up later to apply texture mapping to them.
I've tried delaunay already but it doesn't seem as accurate as my voronoi generation. But being that the cicrumradius is the voronoi vertices anyways i feel like i don't need it. The problem with the Delaunay is that it only returns the points near the center of the diagram and doesn't return any points towards the Borders of the Box. The only good thing is that delaunay did skip an extra step and made it easier to return if the the seeds x and y are within the circumradius then just add them to the list of vertices
Is there any way to make a polygon from a plot of points from a data structure?
Pick the midpoint of each edge and the distance to each site then sort the result and pick the first and second (when they are equal) and save them into polygons. For the borders there is of course only 1 edge.
Duplicate:Getting polygons from voronoi edges

Find the distance between two points on any 3d surface

I am making a game in Unity3d and I need a pathfinding algorithm that can guide enemy's towards the player on a 3d surface. The problem is that the 3d surface can take any shape, so it can be a 3d sphere, cube, torus and many more shapes.
I tried using A* but for that formula I need the distance between the two points, and since the object is curved I cannot get that so easily. I found that you can use the Haversine formula if its a sphere, but that won't work on a torus or a random 3d shape.
I want this kind of result except with every kind of object:
https://www.youtube.com/watch?v=hvunNq7yVcU
Is there a way/algorithm that I can use to get that result. I know there is something called nav mesh but I need to program it myself. Also I cannot find how nav mesh approaches this dilema. I am going to use the triangles of my object as nodes.
So my question boils down to:
Does anyone know a algorithm for pathfinding that works on any 3d surface?
Thanks in advance.
I think your problem is that you are not using a graph, I would suggest that you look into a tutorial on how to create a graph, for the language you are using if you can, (this may also help here they are using edges to connect their node which is needed if you have more then one weight). If you do make a graph you will need a node class. Each node must contain pointers to any nodes that it is connected to and an ID of some kind. In your case that is probably all you need but it is also possible to assign a weight to each move if you also have an edge class (connectors between nodes) which would be used to connect the nodes. If you do have an edge class your nodes will have pointers to edges instead of other nodes and each edge will have a weight and a pointer to 1 or 2 nodes (depending on if it is a directed path or not). You can also make a graph class to contain all of your nodes and edges.
Summary:
make a node class and determine if you need the edge class (if everything has a weight of 1 you can get away with out it). Use the node class to create a graph to represent your map with each tile being a node with pointers to connected tiles. Use A* or dijkstra's algorithm to search your graph to find the shortest path.
note: most examples you will find will be for 2d graphs, yours is no different except that there are no bounds on yours, you just need to connect the nodes to their adjacent tiles.

Building a graph from a point cloud

I have a PCL Point Cloud. Basically, I need to write some code that does the following:
Example
Basically, I need to build a graph/edge map of the point cloud. Where each node represents a point, and those points have pointers/edges to neighbouring points. And preferably, it cannot form a corner edge as seen in the picture. (This could be enforced by saying a point cannot have a large change in l1 norm too (taxicab distance. add all axis), not just l2 norm).
I need to do this because, it's useful for all my other algorithms. Normal computation etc.
I'm currently at a loss of how to implement this. My point cloud is unorganized. I could sort it into a KD Tree but I'm not sure if that is related to this or how I might use this.
The graph/edge map is the same as a triangulation between the vertices.
In your case, as you only want to connect vertices which are close together, Delaunay Triangulation will work.
The edges are the connections between vertices in your graph.
PCL has ConcaveHull, which will triangulate the surface of your vertices, given an alpha value. This alpha value is the maximum radius for each triangle, in your case, half the known distance between diagonal vertices.

find coordinates of vertices of an undirected, unweighted graph

Suppose I have an undirected, unweighted graph, with 'N'(say) vertices. I'm trying to find the co-ordinates of the vertices of the graph.
I don't seem to understand, how can we get the coordinates of the graph, without any function being provided. Is there any standard method we adapt to get the co-ordinates of the graph?
I need these co-ordinates because I want to use them as input parameters(by collecting them and placing in a file and supplying this file as argument) to fd3 program, to calculate the fractal dimension of a network(given coordinates of graph).
I would use the Cluster Growing Method to get the fractal dimension of the system, as opposed to trying to use a box-counting algorithm. It is much better suited to the task when the vertices are not associated with physical space.

shortest path search in a map represented as 2d shapes

I have a small library of a few shortest path search algorithms. They were developed for simple undirected graphs (the normal representation - vertices and edges). Now I'd like to somehow apply them on a bit different scenario - where the maps are represented as 2-dimensional shapes, connected by shared edges (edges of the polygons, that is). In this scenario, the search can start/end either at a map object or some point (x,y). What would be the best approach? Try to apply the algorithms onto shapes? or try to extract a 'normal' graph out of the shapes (I have preprocessing time available)? Any advice would be much appreciated, as I'm really not sure which way to go, and I don't have enough time (and skill) to explore many options...
Thanks a lot
What's the "path" you're looking for? A list of the shapes to traverse? (Otherwise you just draw a straight line between start+end points.)
It's easy to preprocess it into a format where the shapes are vertices and are connected by edges when the shapes share a polygon side. Then, just pass it off to your existing library to get the answer.

Resources