The difference is that dis[k,:] eliminates the first dimension since
you are using a single number as an index, but dis[k:k+1,:] does not
eliminate that dimension.
On Sat, Nov 6, 2010 at 1:24 PM, wrote:
> On Sat, Nov 6, 2010 at 4:14 PM, K. Sun wrote:
>> Thanks a lot. It works! I modify the code
On Sat, Nov 6, 2010 at 4:14 PM, K. Sun wrote:
> Thanks a lot. It works! I modify the code as follows and it runs
> at fast as matlab. By numpy's convention, the input and output
> are all ndarrays. 'route' has to be a (1xN) matrix to produce a
> square matrix in 'route + route.T'.
If you read my
Thanks a lot. It works! I modify the code as follows and it runs
at fast as matlab. By numpy's convention, the input and output
are all ndarrays. 'route' has to be a (1xN) matrix to produce a
square matrix in 'route + route.T'.
def floyd( dis ):
'''Floyd-Wallshall algorithm for shortest path
On Sat, Nov 6, 2010 at 3:28 PM, K. Sun wrote:
> Hello,
>
> I wrote the following code with numpy to implement the Floyd-Wallshall
> algorithm to compute the pair-wise shortest path in a undirected weighted
> graph. It is really slow when N ~ 10k, while the same implementation in
> matlab is much f
Hello,
I wrote the following code with numpy to implement the Floyd-Wallshall
algorithm to compute the pair-wise shortest path in a undirected weighted
graph. It is really slow when N ~ 10k, while the same implementation in
matlab is much faster. I am sorry I don't want to run it again to
present