# Drawing a complete graph of an ego network

I have an ego network (a network of a person (ego) and his friends). It is drawn with the ego at the center surrounded by the friends. It might be possible that all the friends are connected to each other, in which case one can have a complete graph. Mathematica however draws a complete graph with no focal node. How can I make Mathematica draw a complete graph with a center node in it? How can I remove some connections so that it would still be an ego network but not a complete graph? Thanks.

---------- Update -------------

Now because of your comment I understand your problem better. Then it is basically a one-liner:

RandomGraph[{11, 25}, GraphLayout -> {"StarEmbedding", "Center" -> 2},
GraphStyle -> "SmallNetwork"] ---------- Older versions -------------

Start from {"BalloonEmbedding", "RootVertex" -> k} or {"RadialEmbedding", "RootVertex" -> k} where k is the root vertex (focus) - see this and this for the references:

g = CompleteGraph[12,
GraphLayout -> {"BalloonEmbedding", "RootVertex" -> 3},
GraphStyle -> "SmallNetwork"] You got 55 edges in this case

el = EdgeList[g]; el // Length
55


Now remove some of them but preserve embeding:

Manipulate[Graph[EdgeList[g][[1 ;; m]], VertexCoordinates -> GraphEmbedding[g],
GraphStyle -> "SmallNetwork"], {m, 10, 55, 1}] • Could you please link to the doc page of BalloonEmbedding? :) Apr 23 '13 at 23:56
• @belisarius Here. The graph related functionality leaves some to be desired both in documentation and quality though ... Apr 24 '13 at 0:06
• @belisarius I put the link in ;) Apr 24 '13 at 0:08
• Pfff and I was doing everything manually. Well, you can never know all the functionality :). Apr 24 '13 at 0:37
• Thanks Vitaly!You have the things I need...(In your manipulate graph though, my case would be 3 (instead of 1) would be connected to everyone else and its the connections among the friends that would be changing). Thanks a lot! Apr 24 '13 at 1:05

Ideally, it would be possible to fix the coordinates of one vertex, and let the layout algorithm take care of the rest. I couldn't figure out how to do this with Graph, but it is possible with GraphPlot:

GraphPlot[CompleteGraph, VertexCoordinateRules -> {1 -> {0, 0}}] • Thanks a lot Szabolcs! This gives me lots of options! Apr 24 '13 at 1:07
nFriends = 10;
coords = Prepend[#, {0, 0}] &[{Sin@#,
Cos@#} & /@ (Range[nFriends]/nFriends*2 Pi)];
CompleteGraph[nFriends+1, VertexCoordinates -> coords]


Will give you the complete graph with a vertex in the center.

func = Function[xxxx, UndirectedEdge[#, Last[xxxx]] & /@ Most[xxxx]];
connections = Array[Sequence @@ func@Range[0, #] &, nFriends];

Graph[Range[0, nFriends], connections, VertexCoordinates -> coords]


will give you the same thing, but now the connections are given in the variable connections so that you can now edit them. You can then do

connections = DeleteCases[connections,
UndirectedEdge[int1, int2]]


to delete the connection between friend int1 and friend int2 (which have to satisfy int1 < int2). Note that the ego is numbered 0 and he is at the center at position {0,0}.