Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
2  
Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the FAQs! 3) When you see good Q&A, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. ALSO, remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign` –  Vitaliy Kaurov Apr 24 '13 at 0:43
add comment

3 Answers

up vote 3 down vote accepted

---------- 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"]

enter image description here

---------- 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"]

enter image description here

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}]

enter image description here

share|improve this answer
    
Could you please link to the doc page of BalloonEmbedding? :) –  belisarius Apr 23 '13 at 23:56
    
@belisarius Here. The graph related functionality leaves some to be desired both in documentation and quality though ... –  Szabolcs Apr 24 '13 at 0:06
    
@belisarius I put the link in ;) –  Vitaliy Kaurov Apr 24 '13 at 0:08
    
Pfff and I was doing everything manually. Well, you can never know all the functionality :). –  Jacob Akkerboom 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! –  newbie py Apr 24 '13 at 1:05
show 2 more comments

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[10], VertexCoordinateRules -> {1 -> {0, 0}}]

enter image description here

share|improve this answer
    
Thanks a lot Szabolcs! This gives me lots of options! –  newbie py Apr 24 '13 at 1:07
add comment
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}.

share|improve this answer
    
Thanks Jacob for the feedback. –  newbie py Apr 24 '13 at 1:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.