New in Wolfram
Mathematica
8: Graph & Network Modeling
◄
previous
|
next
►
Application Areas
Operations on Graphs
All common graph operations and more are built-in to
Mathematica
8.
In[1]:=
X
style = {VertexStyle -> Directive[Hue[.6, .3, 1], EdgeForm[Hue[.6, .8, .7]]], VertexSize -> 0.2, EdgeStyle -> Hue[.6, .8, .5], ImageSize -> {100, 100}};
In[2]:=
X
name = {"Graph Union", "Graph Disjoint Union", "Graph Difference", "Graph Intersection"};
In[3]:=
X
info = { {g = CycleGraph[4, style], Style["\[Union]", 20], h = StarGraph[4, style], Style["\[LongEqual]", 20], HighlightGraph[ GraphUnion[g, h, GraphLayout -> "CircularEmbedding"], g, style]}, {g = CycleGraph[3, style], Style["\[UnionPlus]", 20], h = CycleGraph[3, style], Style["\[LongEqual]", 20], HighlightGraph[GraphDisjointUnion[g, h], g, style]}, {g = PetersenGraph[5, 2, style], Style["-", 20], h = CompleteGraph[5, style], Style["\[LongEqual]", 20], HighlightGraph[g, GraphDifference[g, h], style]}, {g = PetersenGraph[5, 2, style], Style["\[Intersection]", 20], h = CompleteGraph[5, style], Style["\[LongEqual]", 20], HighlightGraph[g, GraphIntersection[g, h], style]} };
In[4]:=
X
ShowPlotSamples[name_, info_] := Framed[Column[{Style[name, 14, Bold, FontFamily -> "Verdana"], Grid[{info}, Spacings -> {1, 0}]}, Alignment -> Center], RoundingRadius -> 9, FrameStyle -> None, Background -> GrayLevel@0.90];
In[5]:=
X
Column[MapThread[ShowPlotSamples, {name, info}]]
Out[5]=