Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
another question about graphshortestpath()

Subject: another question about graphshortestpath()

From: dhuan Du

Date: 20 Mar, 2009 19:31:01

Message: 1 of 4

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);

Subject: another question about graphshortestpath()

From: Lucio Andrade-Cetto

Date: 20 Mar, 2009 20:54:00

Message: 2 of 4

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);

Subject: another question about graphshortestpath()

From: dhuan Du

Date: 23 Mar, 2009 14:55:04

Message: 3 of 4

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 Andrade-Cetto" <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);

Subject: another question about graphshortestpath()

From: dhuan Du

Date: 23 Mar, 2009 15:23:01

Message: 4 of 4

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 Andrade-Cetto" <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);

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us