[python-uk] Help Please

Python Freak newtopython at gmail.com
Mon Jan 29 06:07:22 CET 2007


Okay, how about this:

I don't know how to create the adjacency list at the first place! Can you
get me started please? If I start then I can make an attempt to create the
incidence list and the adjacency matrix representation. Here is the question
again:

Consider a digraph with 10 vertices, labeled 1 through 10. You are given the
following adjacency list representation, where we first list the vertices
adjacent to vertex 1, and so on.

1*, *2; 2*, *3; 3*, *4; 4*, *5; 5*, *6; 6*, *7; 7*, *8; 8*, *9; 9*, *10; 10.


a) Write code to turn the adjacency list into an incidence list and an an
adjacency matrix.

b) Write code to turn the incidence list into an adjacency matrix.




On 1/28/07, Zeth Green <theology at gmail.com> wrote:
>
> On 29/01/07, Python Freak <newtopython at gmail.com> wrote:
> > I am clueless about where to start.
>
> Okay, I did economics for my first degree so we have something in
> common! (Although I am not sure my maths ever got that deep). There
> are many ways to do what you want. The first step is to mentally
> translate what you want to do into Python's data types.
>
> See here for a list of the basic types:
> http://docs.python.org/tut/node7.html
>
> Do not forget you can nest data types inside each other, so the most
> basic matrix is a set of lists inside a list.
>
> However once you understand what you are trying to do, it would then
> be worth downing tools and looking into the numpy module as it has
> many mathematical constructs all ready and abstracted for you.
>
> Look at http://numpy.scipy.org/ for hours of fun(?). See for example,
>
> https://networkx.lanl.gov/Reference/networkx.convert-module.html#to_numpy_matrix
> _______________________________________________
> python-uk mailing list
> python-uk at python.org
> http://mail.python.org/mailman/listinfo/python-uk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-uk/attachments/20070129/9543cb42/attachment.htm 


More information about the python-uk mailing list