Group Abstract Group Abstract

Message Boards Message Boards

Identifying & linking common vertices in 2 or more unequal multi-graphs?

POSTED BY: Arno Bosse
4 Replies

Marco and Vitaliy, thank you both very much for your patient and generous responses. I will have time tomorrow to look at them more carefully.

POSTED BY: Arno Bosse

...friendships forged in fire ;-) @Arno Bosse @Marco Thiel

POSTED BY: Vitaliy Kaurov
POSTED BY: Vitaliy Kaurov

HI Arno,

I am not sure whether this is what you need, but here are some pieces of code. First I create two similar graphs with some common nodes.

adAuthors = {"mary", "peter", "peter", "peter"};
adRecipients = {"jane", "arthur", "diana", "diana"};
adAuthors2 = {"paul", "victor", "mary", "diana", "peter"};
adRecipients2 = {"peter", "mary", "paul", "paul", "alonso"};

We can plot the graphs separately:

adGraph = 
 Graph[Thread[DirectedEdge[adAuthors, adRecipients]], 
  VertexLabels -> Placed["Name", Tooltip]]

and

adGraph2 = 
 Graph[Thread[DirectedEdge[adAuthors2, adRecipients2]], 
  VertexLabels -> Placed["Name", Tooltip]]

We can user Union to generate a list of all authors and all recipients.

Union[adAuthors, adAuthors2]
(*{"diana", "mary", "paul", "peter", "victor"}*)

and

Union[adRecipients, adRecipients2]
(*{"alonso", "arthur", "diana", "jane", "mary", "paul", "peter"}*)

We can also plot the joint graph like so:

adGraphjoin = 
 Graph[Thread[DirectedEdge[Join[adAuthors, adAuthors2], Join[adRecipients, adRecipients2]]], 
  VertexLabels -> Placed["Name", Tooltip]]

enter image description here

So a combination of Union and Join functions should do the trick for you.

Best wishes from Aberdeen and thanks again for the great conference/workshop in Oxford, Marco

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard