Construction of total graph using SageMath

65 Views Asked by At

Let $G$ be a graph of order $n$ and size $e$. The total graph $T$ is the graph associated to $G$, which consists of order $n+e$ and edges consist of the union of the edges of $G$, the edges of line graph of $G$ and the edges of the subdivision graph of $G$.

I know that there is the line_graph() module in SageMath. But, I am unaware of the any module for subdivision graph. In addition, how do we form a disjoint union of edges of the three graphs $G$, its line and subdivision graphs, when their vertex sets are different. So finally, how can we construct the total graph $T$ in SageMath. Any hints? Thanks beforehand.

1

There are 1 best solutions below

0
On BEST ANSWER

By using the equivalent definition of total graph as the square(or distance-2 graph) of the subdivision graph(the graph formed by subdividing each edge, we obtain the following pseudo-code:

g = Any_desired_graph

k = 1
g.subdivide_edges(g.edges(), k)
h=g.distance_graph(list(range(1,3)))
h.plot()

We can replace the Any_desired_graph by our graph whose total graph is required.