New in Wolfram
Mathematica
8: Graph & Network Modeling
◄
previous
|
next
►
Application Areas
Modify Graphs
New graphs can be constructed from an existing graph by adding or removing a vertex or an edge.
In[1]:=
X
arrow = Row@{" ", \!\(\* GraphicsBox[ {Thickness[0.05263157894736842], FaceForm[{RGBColor[0.7, 0.7, 0.7], Opacity[1.]}], FilledCurveBox[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, { 0, 1, 0}, {0, 1, 0}}}, {{{9.9999, 18.}, {9.9999, 13.5}, {-0.00009999999999976694, 13.5}, {-0.00009999999999976694, 4.5}, {9.9999, 4.5}, { 9.9999, 0.}, {18.9999, 9.}}}]}, AspectRatio->Automatic, ImageSize->{19., 18.}, PlotRange->{{0., 19.}, {0., 18.}}]\), " "};
In[2]:=
X
graph1 = CompleteGraph[3, VertexSize -> {"Scaled", 0.05}, EdgeStyle -> Thick, ImageSize -> 130]; graph2 = CompleteGraph[5, EdgeStyle -> Thick, VertexSize -> Small, ImageSize -> 130]; graph3 = CycleGraph[5, EdgeStyle -> Thick, ImageSize -> 130]; graph4 = CompleteGraph[5, EdgeStyle -> Thick, VertexSize -> Small, ImageSize -> 130];
In[3]:=
X
Column[{Row[{HighlightGraph[VertexAdd[graph1, 4], graph1, GraphHighlightStyle -> "DehighlightHide"], arrow, HighlightGraph[VertexAdd[graph1, 4], graph1, GraphHighlightStyle -> "DehighlightFade"], arrow, VertexAdd[graph1, 4]}], Row[{graph2, arrow, HighlightGraph[graph2, VertexDelete[graph2, 1], GraphHighlightStyle -> "DehighlightFade"], arrow, HighlightGraph[graph2, VertexDelete[graph2, 1], GraphHighlightStyle -> "DehighlightHide"]}], Row[{graph3, arrow, HighlightGraph[EdgeAdd[graph3, 1 \[UndirectedEdge] 3], graph3, GraphHighlightStyle -> "DehighlightFade"], arrow, EdgeAdd[graph3, 1 \[UndirectedEdge] 3]}], Row[{graph4, arrow, HighlightGraph[graph4, EdgeDelete[graph4, 1 \[UndirectedEdge] 2], GraphHighlightStyle -> "DehighlightFade"], arrow, HighlightGraph[graph4, EdgeDelete[graph4, 1 \[UndirectedEdge] 2], GraphHighlightStyle -> "DehighlightHide"]}]}]
Out[3]=