Ask Your Question


asked 2018-05-24 00:10:38 +0200

standardtrickyness gravatar image

So I'm a bit confused by the documentation of graphs.planar_graphs I thought it would just generate a list of planar graphs so I don't know why the following code doesn't work (and also why I need to do list(l) )

l = graphs.planar_graphs(4, dual=False)
gen=list(l) #don't know why this is necessary k=len(gen) ii=1 G=gen[ii] p=G.plot()

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-05-24 17:13:53 +0200

j.c. gravatar image

To check the type of l, you can type ?l. You will see that l is a generator, not a list object. Thus in order to compute its length (and do other list-specific operations) you must convert it to a list using list.

edit flag offensive delete link more


Okay thanks I'll have to read up on what a generator is, but what is wrong after I do gen=list(l) G=gen[ii] p=G.plot

standardtrickyness gravatar imagestandardtrickyness ( 2018-05-24 20:41:00 +0200 )edit

so what is the output of graphs.planar_graphs?

standardtrickyness gravatar imagestandardtrickyness ( 2018-05-25 17:53:23 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-05-24 00:10:38 +0200

Seen: 337 times

Last updated: May 24 '18