Explanation:
Let us consider the graph2
:
z3 = {1 <-> 2, 2 <-> 3, 3 <-> 4, 4 <-> 5, 5 <-> 6, 6 <-> 7, 7 <-> 19,19 <-> 20, 19 <-> 22, 20 <-> 21, 20 <-> 23, 7 <-> 8, 8 <-> 24, 24 <-> 25, 24 <-> 26, 8 <-> 9, 9 <-> 10, 9 <-> 27, 27 <-> 28, 27 <-> 29, 10 <-> 11, 11 <-> 12, 12 <-> 13, 13 <-> 14, 14 <-> 15,15 <-> 16, 16 <-> 17, 17 <-> 18, 12 <-> 30, 30 <-> 31, 31 <-> 32, 32 <-> 33, 30 <-> 34, 31 <-> 35, 32 <-> 36, 34 <-> 37, 34 <-> 38, 2 <-> 39, 3 <-> 40, 4 <-> 41, 5 <-> 42, 6 <-> 43, 10 <-> 44, 11 <-> 45, 13 <-> 46, 14 <-> 47, 15 <-> 48, 16 <-> 49, 17 <-> 50,18 <-> 51, 18 <-> 52, 1 <-> 53, 1 <-> 54}; graph2= Graph[z3,GraphLayout -> "SpringEmbedding",(*VertexLabels\[Rule]"Name",*)EdgeStyle -> Thick].
The color version looks like this:
Let us imagine that it is a network of streets. Red trail markes the longest street. The longest street connects directly to 18 smaller streets - this is the degree of the middle vertex in graph1
. The second longest street is dark blue - this street connects to three other streets... and so on...
In this way we obtain the graph1
. I wrote a script which calculates graph1
based on graph2
(for very large networks).
The question is:
How can we get graph2
from the graph1
?
I think this is not a trivial issue:) Thanks for the help:)
z1 = {1 <-> 2, 1 <-> 3, 1 <-> 4, 1 <-> 5, 1 <-> 6, 1 <-> 7, 1 <-> 8,1 <-> 9, 1 <-> 10, 1 <-> 11, 1 <-> 12, 9 <-> 13, 1 <-> 14, 1 <-> 15,1 <-> 16, 12 <-> 17, 1 <-> 18, 12 <-> 19, 12 <-> 20, 1 <-> 21,1 <-> 22, 1 <-> 23, 8 <-> 24, 4 <-> 25, 4 <-> 26, 20 <-> 27}; graph1 = Graph[z1, GraphLayout -> "RadialDrawing"(*,VertexLabels\[Rule]"Name"*)]
Let us imagine that the driver starts from point 56 (graph2):
Assumption: the driver at a particular point always identifies the longest route! At point 56, the longest route is from point 56 to point 51 (or 52) (red road). And he goes .... He does not look at points 55 and 54 because there are no turns - therefore, in graph 1, the highest node will have 18 degree.
Next, he comes to point 1 and identifies the road towards point 53. There are no other roads from 1 to 53. And so on ... He comes to point 12 and turns and identifies the longest route. The longest route is from point 12 to 33 (or 36) (in graph 1 there will be a node of 4 times). And he goes this way. In point 30 he turns and identifies the longest road - this road is from 30 to 38 (or 37). And he goes ... In 34 is the turn, he identifies the longest path (34-37). Next he goes back to point 30 and goes on further identifying the roads on the route until point 33. Then he goes back to the main road to point 12 and continues to drive. That way we get graph1. The question is: How can we get graph2 from the graph1?
Re-interpretation by b3m2a1: (might not be correct)
Consider the set of edges and its corresponding graph, call it graph2
:
z3 = {1 <-> 2, 2 <-> 3, 3 <-> 4, 4 <-> 5, 5 <-> 6, 6 <-> 7, 7 <-> 19,19 <-> 20, 19 <-> 22, 20 <-> 21, 20 <-> 23, 7 <-> 8, 8 <-> 24, 24 <-> 25, 24 <-> 26, 8 <-> 9, 9 <-> 10, 9 <-> 27, 27 <-> 28, 27 <-> 29, 10 <-> 11, 11 <-> 12, 12 <-> 13, 13 <-> 14, 14 <-> 15,15 <-> 16, 16 <-> 17, 17 <-> 18, 12 <-> 30, 30 <-> 31, 31 <-> 32, 32 <-> 33, 30 <-> 34, 31 <-> 35, 32 <-> 36, 34 <-> 37, 34 <-> 38, 2 <-> 39, 3 <-> 40, 4 <-> 41, 5 <-> 42, 6 <-> 43, 10 <-> 44, 11 <-> 45, 13 <-> 46, 14 <-> 47, 15 <-> 48, 16 <-> 49, 17 <-> 50,18 <-> 51, 18 <-> 52, 1 <-> 53, 1 <-> 54};
graph2= Graph[z3,GraphLayout -> "SpringEmbedding",(*VertexLabels\[Rule]"Name",*)EdgeStyle -> Thick].
We'll colorize the longest chain, the longest branches off of this chain, the longest branches off of that chain, etc... This is the hierarchy we're representing
We can represent this hierarchy by a creating a graph where we have a central node representing the longest chain connected to a node for each subchain, each of which has connections for its subchains, etc.
In doing this we find that the each node has a degree equal to the total path length of the chain. Here's such a construction for the graph2
presented above:
z1 = {1 <-> 2, 1 <-> 3, 1 <-> 4, 1 <-> 5, 1 <-> 6, 1 <-> 7, 1 <-> 8,1 <-> 9, 1 <-> 10, 1 <-> 11, 1 <-> 12, 9 <-> 13, 1 <-> 14, 1 <-> 15,1 <-> 16, 12 <-> 17, 1 <-> 18, 12 <-> 19, 12 <-> 20, 1 <-> 21,1 <-> 22, 1 <-> 23, 8 <-> 24, 4 <-> 25, 4 <-> 26, 20 <-> 27};
graph1 = Graph[z1, GraphLayout -> "RadialDrawing"(*,VertexLabels\[Rule]"Name"*)]
Now, how can one reverse this process? That is, given graph1
can we build a hierarchical graph, graph2'
that would also be reduced back to graph1
?
Note that if we built the compact representation from an original chained graph then we're assured there is one unambiguous solution. If not, then we could hit collisions in interpretation, e.g. consider node with seven connections with two child nodes with 6. No matter where those child nodes are placed along the constructed chain (as only one of them can occupy a given spot) the resultant path will have a length longer than 7 and so will reduce down to a different form than the original.
z2
that was causing you trouble. I believe there shouldn't be a solution to the problem as it's stated for that graph. Revamped much of the code to show it. $\endgroup$