[Numpy-discussion] Graph class
Charles R Harris
charlesr.harris at gmail.com
Tue Aug 1 14:49:00 CDT 2006
Hi David,
I often have several thousand nodes in a graph, sometimes clustered into
connected components. I suspect that using an adjacency matrix is an
inefficient representation for graphs of that size while for smaller graphs
the overhead of more complicated structures wouldn't be noticeable. Have you
looked at the boost graph library? I don't like all their stuff but it is a
good start with lots of code and a suitable license.
Chuck
On 8/1/06, David Grant <davidgrant at gmail.com> wrote:
>
> I have written my own graph class, it doesn't really do much, just has a
> few methods, it might do more later. Up until now it has just had one piece
> of data, an adjacency matrix, so it looks something like this:
>
> class Graph:
> def __init__(self, Adj):
> self.Adj = Adj
>
> I had the idea of changing Graph to inherit numpy.ndarray instead, so then
> I can just access itself directly rather than having to type self.Adj. Is
> this the right way to go about it? To inherit from numpy.ndarray?
>
> The reason I'm using a numpy array to store the graph by the way is the
> following:
> -Memory is not a concern (yet) so I don't need to use a sparse structure
> like a sparse array or a dictionary
> -I run a lot of sums on it, argmin, blanking out of certain rows and
> columns using fancy indexing, grabbing subgraphs using vector indexing
>
> --
> David Grant
> http://www.davidgrant.ca
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys -- and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
>
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060801/40e01831/attachment.html
More information about the Numpy-discussion
mailing list