# Graph plotting not working properly

Consider the following code:

def Sier(g):
h = Graph()
for i in range(1, g.order() + 1):
perm = {u: (i, u) for u in g}
gg = g.relabel(perm=perm, inplace=False)
return h

f = Sier(graphs.CompleteGraph(4))
v = f.vertices()
n1 = [((a, b), (b, a)) for a, b in v]
n2 = [(a, a), (a, a)) for a, b in v]
x = set(n1) - set(n2)
z.plot()


The plot function does not give the graph I desire. The size() function gives the size correctly. But the diagram is incorrect. Why is this? Any workarounds to make it precise?

edit retag close merge delete

The plot function does not give the graph I desire.

What do you desire, exactly ?

Sorry, I'm not a psychiatrist. I'm just running H sapiens sapiens L. v 1.0, without psychic interface. And my aging dvinatory abilities do leave something to desire...

@Emmanuel Charpentier The plot function above gives me a disconnected graph with less number of edges, quite different from the desired size

Sort by » oldest newest most voted

I try to guess, maybe this graph?

def Sier(g):
h = Graph()
for i in range(1, g.order() + 1):
perm = {u: (i, u) for u in g}
gg = g.relabel(perm=perm, inplace=False)
return h
f=Sier(graphs.CompleteGraph(4))
v=f.vertices()
n1=[((a,b),(b,a)) for (a,b) in v]
n2=[((a,a),(a,a)) for (a,b) in v]
x=set(n1)-set(n2)
z=f
z.plot(figsize=14,vertex_size=1000)

more

if not, like Emmanuel asked you we need precisions !

@David Coudert yes, what I wanted in my above plot was the Generalized Sierpinski Graph. But, even after trying the code as given in the answer, I am unable to get my desired graph. My graph is connected, whereas the graph plotted is disconnected. And, moreover, the size of graph does not match the construction.