Basically you need to create a graph based on the nodes of your skeletal image. The vertices of your graph will correspond to the set of nodes.
I suggest you this algorithm for extracting edges of a graph:
For each node, use an 8-neighborhood (8N) to visit all pixel elements. Put the entire skeleton pixel in the queue and continue until you find the node. When the queue is empty, you will have all the edges for this node
source share