4
$\begingroup$

For eg. GraphPlot[{1 -> 2, 2 -> 1, 3 -> 1, 3 -> 2, 4 -> 1, 4 -> 2, 4 -> 4}, VertexLabeling -> True] original graph

Then If I remove the edge (say 1->4) and redraw the graphplot then I have second graph

One can see the structure is not preserved. I want that looks like the same as the first one but without the edge 1->4. i.e., with vertices same at the coordinates as the previous one

My second question: I noticed that if I have a huge graph drawn with the option of Graph not GraphPlot I am not able to resize the vertices. How can I resize them?

$\endgroup$
7
$\begingroup$

If you have a GraphPlot, then it is simply a Graphics object, and you can't do any of the interactive things you can do with a Graph. Look here for info on the differences between the two functions.

If you want the vertices for the second GraphPlot to have the same coordinates as the first, then you need to specify the VertexCoordinateRules. To do this, you need a list of coordinates, which you can get from a Graph, but not from a GraphPlot. So first you have to create a graph from the edge rules, extract the coordinates via the GraphEmbedding function, and feed those back into either Graph or GraphPlot.

edgelist = {1 -> 2, 2 -> 1, 3 -> 1, 3 -> 2, 4 -> 1, 4 -> 2, 4 -> 4};
With[{g = Graph[edgelist]},
 {
  GraphPlot[
   DeleteCases[edgelist, 4 -> 1],
   VertexLabeling -> True, 
   VertexCoordinateRules -> 
    Thread[VertexList[g] -> GraphEmbedding[g]]],
  Graph[
   DeleteCases[edgelist, 4 -> 1],
   VertexLabels -> "Name", 
   VertexCoordinates -> Thread[VertexList[g] -> GraphEmbedding[g]]]
  }
 ]

Mathematica graphics

Only in the Graph can you resize the vertices.

$\endgroup$
1
$\begingroup$

Jason probably has answer you need but I choose to take a blindingly simple interpretation of the question, and offer:

GraphPlot[
  {1 -> 2, 2 -> 1, 3 -> 1, 3 -> 2, 4 -> 1, 4 -> 2, 4 -> 4}
  , VertexLabeling -> True
] /. {4, 1} -> Sequence[]

enter image description here

For the second question you should be able to use either VertexRenderingFunction or VertexSize, for GraphPlot and Graph respectively. Give a specific example of what you need and I'll try to provide a solution.

$\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.