Skip to main content
3 of 4
added 1502 characters in body

Layout a second graph of the same nodes in the same way

I have a number of graphs with the same nodes.

I would like to be able to somehow save the layout that results from the spring embedded results of one graph (the first image), and have the other graphs position the nodes in the same locations (which would otherwise get you the second image).

Not sure if there is a property of the first graph that can be applied to the second. Or whether I need to create a manual set of coordinates using VertexCoordinates to apply to each.

Ideas?

enter image description here

enter image description here

The data for the two graphs is

{"Al-1" -> "Bru-2", "Bru-2" -> "Gra-7", "Chas-3" -> "Ned-14", 
 "Dave-4" -> "Bru-2", "Ed-5" -> "Ned-14", "Frank-6" -> "Unwin-21", 
 "Hal-8" -> "Unwin-21", "Ian-9" -> "Ned-14", "Jo-10" -> "Ron-18", 
 "Ken-11" -> "Ron-18", "Leo-12" -> "Unwin-21", "Mal-13" -> "Ned-14", 
 "Ned-14" -> "Gra-7", "Ollie-15" -> "Ned-14", "Pat-16" -> "Bru-2", 
 "Quinn-17" -> "Unwin-21", "Ron-18" -> "Gra-7", "Sam-19" -> "Ned-14", 
 "Tom-20" -> "Ned-14", "Unwin-21" -> "Gra-7"}

and

{"Al-1" -> "Bru-2", "Al-1" -> "Dave-4", "Al-1" -> "Hal-8", 
 "Al-1" -> "Leo-12", "Al-1" -> "Pat-16", "Bru-2" -> "Al-1", 
 "Bru-2" -> "Ron-18", "Bru-2" -> "Unwin-21", "Chas-3" -> "Ned-14", 
 "Chas-3" -> "Sam-19", "Dave-4" -> "Al-1", "Dave-4" -> "Bru-2", 
 "Dave-4" -> "Hal-8", "Dave-4" -> "Leo-12", "Dave-4" -> "Pat-16", 
 "Dave-4" -> "Quinn-17", "Ed-5" -> "Bru-2", "Ed-5" -> "Ian-9", 
 "Ed-5" -> "Ken-11", "Ed-5" -> "Ned-14", "Ed-5" -> "Quinn-17", 
 "Ed-5" -> "Sam-19", "Ed-5" -> "Unwin-21", "Frank-6" -> "Bru-2", 
 "Frank-6" -> "Gra-7", "Frank-6" -> "Ian-9", "Frank-6" -> "Leo-12", 
 "Frank-6" -> "Quinn-17", "Frank-6" -> "Unwin-21", 
 "Hal-8" -> "Dave-4", "Jo-10" -> "Chas-3", "Jo-10" -> "Ed-5", 
 "Jo-10" -> "Hal-8", "Jo-10" -> "Ian-9", "Jo-10" -> "Leo-12", 
 "Jo-10" -> "Pat-16", "Jo-10" -> "Tom-20", "Ken-11" -> "Al-1", 
 "Ken-11" -> "Bru-2", "Ken-11" -> "Chas-3", "Ken-11" -> "Dave-4", 
 "Ken-11" -> "Ed-5", "Ken-11" -> "Hal-8", "Ken-11" -> "Ian-9", 
 "Ken-11" -> "Leo-12", "Ken-11" -> "Mal-13", "Ken-11" -> "Ollie-15", 
 "Ken-11" -> "Quinn-17", "Ken-11" -> "Ron-18", "Ken-11" -> "Sam-19", 
 "Leo-12" -> "Al-1", "Leo-12" -> "Dave-4", "Leo-12" -> "Quinn-17", 
 "Leo-12" -> "Unwin-21", "Mal-13" -> "Ed-5", "Mal-13" -> "Ken-11", 
 "Ned-14" -> "Gra-7", "Ned-14" -> "Ollie-15", "Ollie-15" -> "Al-1", 
 "Ollie-15" -> "Chas-3", "Ollie-15" -> "Ed-5", 
 "Ollie-15" -> "Frank-6", "Ollie-15" -> "Ian-9", 
 "Ollie-15" -> "Ken-11", "Ollie-15" -> "Ned-14", 
 "Ollie-15" -> "Sam-19", "Pat-16" -> "Al-1", "Pat-16" -> "Bru-2", 
 "Quinn-17" -> "Al-1", "Quinn-17" -> "Bru-2", "Quinn-17" -> "Chas-3", 
 "Quinn-17" -> "Dave-4", "Quinn-17" -> "Ed-5", 
 "Quinn-17" -> "Frank-6", "Quinn-17" -> "Gra-7", 
 "Quinn-17" -> "Hal-8", "Quinn-17" -> "Ian-9", "Quinn-17" -> "Jo-10", 
 "Quinn-17" -> "Ken-11", "Quinn-17" -> "Leo-12", 
 "Quinn-17" -> "Ned-14", "Quinn-17" -> "Ollie-15", 
 "Quinn-17" -> "Pat-16", "Quinn-17" -> "Sam-19", 
 "Quinn-17" -> "Tom-20", "Quinn-17" -> "Unwin-21", 
 "Ron-18" -> "Bru-2", "Sam-19" -> "Al-1", "Sam-19" -> "Bru-2", 
 "Sam-19" -> "Chas-3", "Sam-19" -> "Ed-5", "Sam-19" -> "Ken-11", 
 "Sam-19" -> "Leo-12", "Sam-19" -> "Ned-14", "Sam-19" -> "Ollie-15", 
 "Sam-19" -> "Tom-20", "Tom-20" -> "Ken-11", "Tom-20" -> "Ron-18", 
 "Unwin-21" -> "Bru-2", "Unwin-21" -> "Leo-12", 
 "Unwin-21" -> "Quinn-17", "Unwin-21" -> "Ron-18"}

UPDATE

It would also be ideal to be able to colour-code the vertexes according to the the final column in the list below (numbered from 0 to 4).

{{"Al-1", 33., 9.333, 3., 4.}, {"Bru-2", 42., 19.583, 2., 
  4.}, {"Chas-3", 40., 12.75, 3., 2.}, {"Dave-4", 33., 7.5, 3., 
  4.}, {"Ed-5", 32., 3.333, 3., 2.}, {"Frank-6", 59., 28., 3., 
  1.}, {"Gra-7", 55., 30., 1., 0.}, {"Hal-8", 34., 11.333, 3., 
  1.}, {"Ian-9", 62., 5.417, 3., 2.}, {"Jo-10", 37., 9.25, 3., 
  3.}, {"Ken-11", 46., 27., 3., 3.}, {"Leo-12", 34., 8.917, 3., 
  1.}, {"Mal-13", 48., 0.25, 3., 2.}, {"Ned-14", 43., 10.417, 2., 
  2.}, {"Ollie-15", 40., 8.417, 3., 2.}, {"Pat-16", 27., 4.667, 3., 
  4.}, {"Quinn-17", 30., 12.417, 3., 1.}, {"Ron-18", 33., 9.083, 2., 
  3.}, {"Sam-19", 32., 4.833, 3., 2.}, {"Tom-20", 38., 11.667, 3., 
  2.}, {"Unwin-21", 36., 12.5, 2., 1.}}

I can easily make up a labelling type of table

{{"Al-1" -> 3.}, {"Bru-2" -> 2.}, {"Chas-3" -> 3.}, {"Dave-4" -> 
   3.}, {"Ed-5" -> 3.}, {"Frank-6" -> 3.}, {"Gra-7" -> 
   1.}, {"Hal-8" -> 3.}, {"Ian-9" -> 3.}, {"Jo-10" -> 
   3.}, {"Ken-11" -> 3.}, {"Leo-12" -> 3.}, {"Mal-13" -> 
   3.}, {"Ned-14" -> 2.}, {"Ollie-15" -> 3.}, {"Pat-16" -> 
   3.}, {"Quinn-17" -> 3.}, {"Ron-18" -> 2.}, {"Sam-19" -> 
   3.}, {"Tom-20" -> 3.}, {"Unwin-21" -> 2.}}

But do I map the number to a colour? I was thinking some kind of rule {0->Black,1->Blue,2->Green,3->Red,4->Yellow}, but exactly where to apply it just for colouring I am not sure.