Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to plot a graph in such a way that

  1. The vertices are labeled using labels that I've given them, rather than just their number,

  2. I can manually move the vertices around.

In the code below, A is my 4 x 4 adjacency matrix, and People specifies the labels that I'd like for the 4 vertices. AG gives me a graph that accomplishes (1) but not (2). GP gives me a graph that satisfies (2) but not (1) -- it only labels the vertices by their number. How can I accomplish both (1) and (2) simultaneously? GraphPLot does not seem to allow for VertexLabels as an option, so I'm at a loss here.

A = {{0, 1, 1, 1}, {1, 0, 0, 0}, {1, 0, 0, 1}, {1, 0, 1, 0}}
People = {Bob, Eric, Lucy, Liz}
AG = AdjacencyGraph[A, VertexLabels -> Table[i -> People[[i]], {i, 1, Length[People]}]]
GP = GraphPlot[AG, VertexLabeling -> True]
share|improve this question
up vote 1 down vote accepted
aA = {{0, 1, 1, 1}, {1, 0, 0, 0}, {1, 0, 0, 1}, {1, 0, 1, 0}};
people = {Bob, Eric, Lucy, Liz};
aG = AdjacencyGraph[aA, ImageSize -> 400, 
  VertexLabels -> Table[i -> people[[i]], {i, 1, Length[people]}], ImagePadding -> 20];
gP = GraphPlot[EdgeList@aG /. UndirectedEdge -> Rule /. 
      Thread[Range@Length@people -> people], ImageSize -> 400,  VertexLabeling -> True];
Row[{aG, gP}, Spacer[5]]

enter image description here

share|improve this answer

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.