Given a Node-Labeled graph, i.e., a graph where only vertices have labels, I would like to create an equivalent Edge-Labeled graph, i.e., a graph where only edges have labels.
I know how to do the opposite.
In particular, given an edge-labeled node-unlabeled graph, I can transform each labeled edge (with unlabeled source and destination) to a pair of edges with a new node, where the original source and destination nodes have a default NIL
label, the new node has label the original edge-label, and the edge (s)-label-(d)
becomes the pair of edges (s)--(label)
and (label)--(d)
.
Best Answer
From the various comments, here is the possible solutions I've found:
1) Construct the corresponding Line Graph, informally meaning:
For each new node, connect it to all other new nodes that have the same incident node in the original graph (in practice each node in the graph is transformed into a clique)
(by @bob-krueger)
1.1) Pros/Cons
2) Transfer Node labels directly onto Edges
v
is labeled by a labell(v)
(v,u)
by a pair(l(v),l(u))
(in practice one can concatenate strings)
(by @alex-ravsky)
2.1) Pros/Cons
2bis) Transfer Node labels directly onto Edges, preserve direction
** this is only for node labeled, edge directed graphs. **
v
is labeled by a labell(v)
, andl(v)
2.1) Pros/Cons