I have some data of corporate board members in Australia in excel format here (Dropbox public link). It is the data behind this graph. The first worksheet is of all the vertexes (directors and companies with a unique ID for each, and a market capitalisation to use for weighting the size of vertexes in displayed graphs). The second worksheet is the relationship between companies and directors (edges).
The edges table looks a bit like this
{{"Source", "Target"}, {"BHP BILLITON",
"Mr Alberto Calderon"}, {"BHP BILLITON",
"Mr Andrew Mackenzie"}, {"BHP BILLITON",
"Mr Brendan Harris"}, {"BHP BILLITON",
"Mr Carlos Cordeiro"}, {"BHP BILLITON",
"Ms Carolyn Hewson"}, {"BHP BILLITON",
"Mr David Crawford, AO"}, {"BHP BILLITON",
"Mr Graham Kerr"}, {"BHP BILLITON",
"Mr Jac Nasser, AO"}, {"BHP BILLITON",
"Dr John Buchanan"}, {"BHP BILLITON",
"Dr John Schubert, AO"}, {"BHP BILLITON",
"Ms Karen Wood"}, {"BHP BILLITON",
"Mr Keith Rumble"}, {"BHP BILLITON", "Mr Lindsay Maxsted"}...
What I ultimately want is a graph of that eliminates the companies, with undirected edges between only directors who are on boards together.
ASXdata =
Import["https://dl.dropbox.com/u/3997716/ASXdata.xls"];
ASXvertexes = Take[ASXdata[[2]]];
ASXedges = Take[ASXdata[[1]]];
graphFunc = Function[{u, v}, v \[UndirectedEdge] u];
twoMode = graphFunc @@@ ASXvertexes;
twoModeGraph = Graph[twoMode, ImageSize -> 500]
The above code gets me the below 2-mode graph (includes company and director vertexes).
Somehow I want a function that assigns all the possible undirected edges between the directors that have the same company in the first column.
I should then see a graph that looks a bit like the below snippet (my previous function can turn it into an undirected graph).
{{Mr ALberto Calderon,Mr Andrew Mackenzie},{Mr Alberto Calderon, Mr Brendan Harris}...
Obviously the graph will be much bigger because of all the extra edges required - eg. for the 21 directors in BHP there will now be 210 edges between them, instead of the previous 21 between the company and each director.
Ideally I could also create a network for just companies, with edges where they share a common board member. I literally have no idea how to even start, but assume I could apply whatever function someone can come up with to the columns in reverse for this.
{{BHP BILLITON, ASCIANO},{ANZ,TELSTRA}...
I guess the other main question, since I intend to be doing this sort of stuff quite a bit, is whether I first map the unique numerical vertex IDs from the first worksheet in the spreadsheet before doing these type of operations and before working with the resulting graph (measuring centrality, components, clusters, paths etc).
UPDATE
I have been able to divide the edges list by company. I figured that I would take the director name list for each company that comes from this, them make a complete graph of each, then combine them. However CompleteGraph doesn't seem to like the list input
ASXvertexes = Take[ASXdata[[1]]];
ASXedges = Take[ASXdata[[2]]];
tASXedges = Transpose[ASXedges];
graphFunc = Function[{u, v}, v \[UndirectedEdge] u];
twoMode = graphFunc @@@ ASXedges;
twoModeGraph = Graph[twoMode, ImageSize -> 500];
compnames = Union[Transpose[ASXedges][[1]]];
directornames = Union[Transpose[ASXedges][[2]]];
t = Split[Rest@tASXedges[[1, All]]];
match = Table[
Cases[ASXedges, {n_, __} /; n == compnames[[b]]], {b, 1,
Length[compnames]}]
c1 = Flatten[Take[Flatten[Take[match, 1], 1], All, -1]]
CompleteGraph[c1]
Which gives as output
CompleteGraph[{"Mr Bill Bartlett", "Mr Rod De Aboitiz",
"Mr Malcolm G Irving", "Mr John M Thame", "Dr Frank M Wolf",
"Mr David Bastian", "Mr Ellis Varejes", "Mrs Myra Salkinder",
"Mr Neil Summerfield"}]
UPDATE 2
With a bit of help from @kguler I can assign unique IDs to the names, and do a bit of sorting.
But for some reason the Graph function won't accept what I give it (it looks like a reasonably constructed graph to me). I get the error message "Graph::supp : Mixed graphs and multi graphs are not supported>>"
I've had this problem before, but I though the filtering of Union, DeleteCases etc would have done it.
Here's the current code
ASXdata =
Import["https://dl.dropbox.com/u/3997716/ASXdata.xls"];
ASXvertexes = Take[ASXdata[[1]]];
ASXedges = Drop[Take[ASXdata[[2]]], 1];
graphFunc = Function[{u, v}, v \[UndirectedEdge] u];
compnames = Union[Transpose[ASXedges][[1]]];
directornames = Union[Transpose[ASXedges][[2]]];
edges = ArrayComponents[ASXedges];
blist = Flatten[Take[edges, All, 1]];
match = Table[Cases[edges, {n_, __} /; n == b], {b, blist}];
directorgroups =
Union[Table[Part[match, i, All, 2], {i, 1, Length[match]}]];
example =
Sort[
Flatten[
Table[
DeleteCases[
Union[
Tuples[directorgroups[[i]]
, 2],
SameTest -> (First[#1] == Last[#2] &)]
, _List?(Equal @@ # &)]
, {i, 1, Length[directorgroups]}]
, 1]
]
testdirectorgraph = graphFunc @@@ example;
Graph[testdirectorgraph]
Many thanks again.
Graph[DeleteDuplicates[testdirectorgraph]]
orGraphPlot[testdirectorgraph /. UndirectedEdge -> Rule]
. (Graph
does not support mixed graphs (mixture of directed and and undirected edges) or multi-graphs (graphs with duplicate edges)). $\endgroup$