[Numpy-discussion] Graph class

David Grant davidgrant at gmail.com
Tue Aug 1 12:40:35 CDT 2006


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060801/3bbc9bb3/attachment.html 


More information about the Numpy-discussion mailing list