Ask Your Question


asked 2018-05-23 17:10:38 -0500

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 10:13:53 -0500

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 13:41:00 -0500 )edit

so what is the output of graphs.planar_graphs?

standardtrickyness gravatar imagestandardtrickyness ( 2018-05-25 10:53:23 -0500 )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-23 17:10:38 -0500

Seen: 43 times

Last updated: May 24