how do i create a network / graph from nodes and lines?

4 views (last 30 days)
Hi,
I am trying to make a logistic simulator and want to create a node/line network from a travelmap. The image displays the routes on the map whichhave different gray scales for different travelling speeds.
I used the help from "image analyst" (tx!) do extract nodes and labelled paths:
  1. extract skeleton from image, converted to 1/0 binary (Black/White) matrix
  2. extract branchpoints
  3. extract line segments using dilated branchpoints
  4. label line segments
bwSkel = bwmorph(binaryImage, 'skel', inf);
bp = bwmorph(bwSkel, 'branchpoints');
bI = bwSkel & ~bwmorph(bp,'dilate');
labeledImage = bwlabel(bI);
I got this:
How do I create a node-network/graph from the branchpoints and linesegments which will allow me to use algo's like travelling salesman problem?
I want the salesman to travel from A to B constrained so that he has to visit one of a selected set of nodes (hubs) before continuing his journey to the endpoint. He may have multiple endpoints which he has to visit.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!