Ok, Thanks. I got it. My previous code includes the node which is not in the graph. This is because the topology of the graphs will be changed under certain condition and I did not change the OD correspondingly.
Thanks again.
"dhuan Du" <dupeony@gmail.com> wrote in message <gq87s8$sqn$1@fred.mathworks.com>...
> Hi,
>
> T is the destination node. I would like to calcuate the shortest path from node 1 (S=1)to node 4(T=4), Why I need to put T=5?
>
> Thanks,
>
> Dhuan
> "Lucio AndradeCetto" <lcetto@nospam.mathworks.com> wrote in message <gq0vp8$8r7$1@fred.mathworks.com>...
> > In your graph there is no node 5, in the code you put T=5
> > Lucio
> >
> > "dhuan Du" <dupeony@gmail.com> wrote in message <gq0qtl$7f7$1@fred.mathworks.com>...
> > > Hi,
> > >
> > > I am using graphshortestpath() to calculate the shortest path of SG with Origin S=1 and destination T=4. But I met the error below. I think the length of the graph SG is 4, why graphshortestpath() try to access dist(5) ? I do not know how to deal with.
> > > Could any one give me some suggestions?
> > >
> > > SG =
> > >
> > > (1,2) 14.1571
> > > (2,3) 42.0277
> > > (2,4) 70.9728
> > >
> > >
> > > lenght of SG =
> > >
> > > 4
> > >
> > >
> > > S =
> > >
> > > 1
> > >
> > >
> > > T =
> > >
> > > 5
> > > >>graphshortestpath(SG, S, T)
> > >
> > > ??? Attempted to access dist(5); index out of bounds because numel(dist)=4.
> > >
> > > Error in ==> graphshortestpath at 148
> > > dist = dist(D);
