[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Speed of #t
- From: Luis Carvalho <lexcarvalho@...>
- Date: Mon, 13 Dec 2010 10:05:45 -0500
> I'm storing the adjacency matrix of a directed graph F as a full array
> of sparse arrays: if F[a][b] is not nil, the edge from a to b exists.
> I want to program an algorithm from "Combinatorial Algorithms" which
> starts:
> 1. Let a be any node in the graph. -- easy, a=1 will do.
> 2. Let b be any neighbour of a. -- easy, b=#F[a]. b==0 means a is isolated.
>
> Think about it. How else can you do it?
If you have sparse arrays then it's probably better to use adjacency lists:
w = true -- or any weight
G = {a = {b = w}}
1. Any node in the graph: a = next(G)
2. Any neighbor of a: b = next(G[a])
Cheers,
Luis
--
Computers are useless. They can only give you answers.
-- Pablo Picasso
--
Luis Carvalho (Kozure)
lua -e 'print((("lexcarvalho@NO.gmail.SPAM.com"):gsub("(%u+%.)","")))'
- References:
- Re: Speed of #t, Enrico Colombini
- Re: Speed of #t, Axel Kittenberger
- Re: Speed of #t, Enrico Colombini
- Re: Speed of #t, David Kastrup
- Re: Speed of #t, Enrico Colombini
- Re: Speed of #t, David Kastrup
- Re: Speed of #t, Enrico Colombini
- Re: Speed of #t, Roberto Ierusalimschy
- Re: Speed of #t, Axel Kittenberger
- Re: Speed of #t, Dirk Laurie