-
-
Notifications
You must be signed in to change notification settings - Fork 376
Line Graphs study for TRSP
What is a Line Graph?
Given a graph G, its line graph L(G) is a graph such that:-
-
each vertex of
L(G)represents an edge ofG. -
two vertices of
L(G)are adjacent if and only if their corresponding edges share a common endpoint inG.
The following figures show a graph (left, with blue vertices) and its line graph (right, with green vertices).

-
Cost associated with the nodes
-
Consider the following graph with nodes having costs:-
The above graph is taken from the sample dataThe transformed Line Graph:-

Each node of the transformed graph is an edge from the original graph. Here
[1,2]denotes the node in the transformed graph which was an edge from node1to node2in the original graph.Each edge of the transformed graph is a tuple of nodes
(n1, n2, n3)wheren1,n2andn3are nodes from the original graph such that there was an edge fromn1 -> n2and another edge fromn2 -> n3.Thus, the connection
[1,4] -> [3, 4]goes through the vertex4as it is made up of(1, 4, 3)tuple which has an associated cost of6therefore the corresponding edge in the above graph gets a cost of6.
-
-
Cost associated with the edges
-
Consider the following graph with edges having costs:-
The above graph is taken from the sample dataThe transformed Line Graph:-

Here, the cost associated with an edge in the original graph moves to the corresponding nodes in the transformed Line Graph.
-
Here is the code that converts a graph into its Line Graph(This graph is limited to very small graphs with nodes <= 10).