# Line graph of a given graph Anonymous

I tried this code in sage. But in the output the vertex labelling of the desired line graph gets overlapped and hece the graph is not clearly visible. Can I improve the code so that the line graph is clearly visible without overlapping.

G=graphs.EmptyGraph()

G.show()

h = G.line_graph()

h.show()

edit retag close merge delete

Sort by » oldest newest most voted

The vertices of the line_graph are the edges of the graph, including edge labels by default. If you don't want the labels, you can do:

sage: G = Graph([(2,3),(2,4),(2,1),(1,5),(5,6),(1,0),(0,12),(0,13),(14,0),(15,0),(7,0),(7,10),(11,7),(7,9),(7,8)])
sage: h = G.line_graph(labels=False)


Then you can either use the method that has already been proposed here, or use the Javascript plotting (it's better to increase the link distance).

sage: h.show(method='js',link_distance=100)

more You could try to read the documentation.

sage: h.relabel(lambda u:u[:2])
sage: h.plot(figsize=12,vertex_size=1200)

more

Can you give us a link to the exact place? While http://doc.sagemath.org/html/en/refer... has references to vertex_size, the line_graphdoc (http://doc.sagemath.org/html/en/refer...) doesn't mention it. And your relabeling is pretty hermetic if the user doesn't know much Python yet.