I'm using Mathematica 9 and want to delete a single vertex and all associated edges on a graph but can't seem to get the function VertexDelete function to work. My code is below. I declare a graph "newgraph" and GraphPlot works fine but when I call VertexDelete I get the following error:
VertexDelete::graph: A graph object is expected at position 1 in VertexDelete[{0->1,0->3,0->6,0->11,0->12,0->14,0->30,0->56,0->75,0->76,0->78,0->86,0->94,0->112,0->120,0->222,0->232,0->248,0->504,0->960,1->7,1->12,1->14,1->15,1->31,1->57,1->62,1->75,1->76,1->78,1->79,1->86,1->94,1->95,1->112,1->116,1->120,1->121,1->124},79]. >>
My code is:
newgraph = {0 -> 1, 0 -> 3, 0 -> 6, 0 -> 11, 0 -> 12, 0 -> 14,
0 -> 30, 0 -> 56, 0 -> 75, 0 -> 76, 0 -> 78, 0 -> 86, 0 -> 94,
0 -> 112, 0 -> 120, 0 -> 222, 0 -> 232, 0 -> 248, 0 -> 504,
0 -> 960, 1 -> 7, 1 -> 12, 1 -> 14, 1 -> 15, 1 -> 31, 1 -> 57,
1 -> 62, 1 -> 75, 1 -> 76, 1 -> 78, 1 -> 79, 1 -> 86, 1 -> 94,
1 -> 95, 1 -> 112, 1 -> 116, 1 -> 120, 1 -> 121, 1 -> 124}
GraphPlot[newgraph, VertexLabeling -> True]
VertexDelete[newgraph, 79]
As far as I am aware, I am indeed passing a graph as an argument! Someone please help me!
Many thanks.
Read the FAQs
! 3) When you see good Q&A, vote them up byclicking 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
` $\endgroup$