2
$\begingroup$

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]
$\endgroup$
2
$\begingroup$
aA = {{0, 1, 1, 1}, {1, 0, 0, 0}, {1, 0, 0, 1}, {1, 0, 1, 0}};
people = {Bob, Eric, Lucy, Liz};

aG1 = AdjacencyGraph[people, aA, ImageSize -> 300, 
  VertexLabels -> "Name", ImagePadding -> 20];
aG2 = AdjacencyGraph[aA, ImageSize -> 300, 
   VertexLabels -> Table[i -> people[[i]], {i, 1, Length[people]}], 
   ImagePadding -> 20];
gP = GraphPlot[Rule @@@ EdgeList[aG1], ImageSize -> 300,  VertexLabeling -> True];
Row[{aG1, aG2, gP}, Spacer[5]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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