Hi all,
I am struggling the question, please see attachments.

Thanks a lot

graph theory (permutation)-2017-04-09-2-.pnggraph theory (permutation)-2017-04-09-1-.png

Devise an algorithm which, given a (directed) friendship graph (in the xkcd format), finds the optimal seating arrangement. Your algorithm should include the following:
 a description of the required input format
 appropriate weightings of the four types of edges in the given friendship graph
 an output (an optimal seating arrangement)
 sufficient explanation of the variables and data structures involved that the marker can tell what they are for.