Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am doing dijkstra algorithm using Matlab . Here is my code

W = [10 8 5 3 7 2 4 6 21];
DG = sparse([1 1 1 2 2 3 4 5 6],[2 4 3 4 5 6 6 6 1],W)

h = view(biograph(DG,[],'ShowWeights','on'))

[dist,path,pred] = graphshortestpath(DG,1,6)

set(h.Nodes(path),'Color',[1 0.4 0.4])
edges = getedgesbynodeid(h,get(h.Nodes(path),'ID'));
set(edges,'LineColor',[1 0 0])
set(edges,'LineWidth',1.5)

The problem is how do i get the red color lines nodes and edges of the shortest path "reset". for example I want it to be [dist,path,pred] = graphshortestpath(DG,2,3) but the graph still shows the

[dist,path,pred] = graphshortestpath(DG,1,6). 
share|improve this question
add comment (requires an account with 50 reputation)

1 Answer

This will do it:

set(h.edges, 'LineColor', [0.5 0.5 0.5])
set(h.edges, 'LineWidth', 0.5)
set(h.nodes, 'Color', [1 1 0.7])

You can inspect all the other properties you can change by simply doing get(h).

There is also some good online info about setting properties of biograph objects:

http://www.mathworks.com/help/toolbox/bioinfo/ref/setbiograph.html

share|improve this answer
add comment (requires an account with 50 reputation)

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.