I have two directed graphs given below:
one={1 -> 2, 1 -> 3, 3 -> 4, 4 -> 1};
two={1 -> 2, 1 -> 3, 1 -> 4};
I simply want to map the two graphs as a single graph keeping all the edges repeated as multiple edges
like 1->2, 1->3. I tried
GraphUnion[one, two]
but it is not giving me what I am after. I want to keep all the edges in these two graphs and differentiate the two graphs with different colors.
Any idea?
Example 2
one = {1 \[DirectedEdge] 10, 3 \[DirectedEdge] 5, 3 \[DirectedEdge] 6,
6 \[DirectedEdge] 1, 6 \[DirectedEdge] 2, 6 \[DirectedEdge] 3,
6 \[DirectedEdge] 4, 6 \[DirectedEdge] 7, 6 \[DirectedEdge] 8,
6 \[DirectedEdge] 11, 6 \[DirectedEdge] 12, 6 \[DirectedEdge] 13,
6 \[DirectedEdge] 14, 6 \[DirectedEdge] 15, 6 \[DirectedEdge] 16,
6 \[DirectedEdge] 17, 11 \[DirectedEdge] 9};
two = {1 \[DirectedEdge] 6, 2 \[DirectedEdge] 6, 3 \[DirectedEdge] 6,
4 \[DirectedEdge] 6, 5 \[DirectedEdge] 6, 6 \[DirectedEdge] 8,
7 \[DirectedEdge] 6, 8 \[DirectedEdge] 6, 9 \[DirectedEdge] 8,
10 \[DirectedEdge] 6, 11 \[DirectedEdge] 9, 12 \[DirectedEdge] 6,
13 \[DirectedEdge] 9, 14 \[DirectedEdge] 6, 15 \[DirectedEdge] 6,
16 \[DirectedEdge] 6, 17 \[DirectedEdge] 6};
HighlightGraph[EdgeAdd[Graph[one, VertexLabels -> "Name"], two], two,
VertexLabels -> "Name"]
GraphUnion[one, two, VertexLabels -> "Name"]
In Highlight
there is something wrong because there are two edges like 11->9
, and only one of them should be RED, the other be BLUE. It seems that identical edges are assumed to belong to graph two
only. What I am after is to separate them with different colors as the colors have a meaning in the context.
GraphUnion
is not generating the same graph at all because it takes mathematical union of the two graphs, eliminating the repeated edges.
I simply want to map two separate graphs with different colors on top of each other without loosing any directed edge.
Graph@Join[one, two]
? $\endgroup$