How to read a Hamiltonian graph image and generate a corresponding game object?

Hello guys!
I’m trying to make a hamiltonian graph game and my problem is:
How to create a graph (with vertexes and edges are game objects) from a available image like this:

I don’t know whether unity support to detect position of the vertexes in the image to generate to game objects in game.
I’m looking forward to all solutions from you.
Thanks in advance!

This is a non-trivial problem.

First things, first. Unity doesn’t support working with images like that, so you will have to write c# code to process the image. I’m quite sure there are c# libraries to ease the task, but I can’t recommend any, because I’ve never done image processing in c#.

Here’s what I would do. Although there’s probably better ways, this should get you started:

  1. Apply a threshold filter, so that all pixels with colors below the threshold are black, and the rest are white.

  2. Apply a clustering algorithm. Any should do the job, because the problem is quite well defined. You can use k-means for instance. If you know the number of vertices, introduce it to the algorithm. Otherwise, you will have to iterate over different values of k and choose the one that minimizes intra-cluster distance.

  3. Finally, for each cluster, calculate the centroid.

You should end up with the coordinates (in image pixel space) of the vertices.

I hope this helps.