New in Wolfram
Mathematica
8: Graph & Network Analysis
◄
previous
|
next
►
Application Areas
Study Properties of an Undirected Graph
Mathematica
8 provides a broad range of functions for computing properties of undirected graphs.
In[1]:=
X
g = \!\(\* GraphicsBox[ NamespaceBox["NetworkGraphics", DynamicModuleBox[{Typeset`graph = HoldComplete[ Graph[{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}, { Null, {{13, 16}, {4, 13}, {1, 8}, {4, 7}, {12, 19}, {4, 15}, {8, 15}, {7, 16}, {13, 20}, {10, 13}, {3, 10}, {10, 19}, {8, 17}, {9, 18}, {15, 18}, {6, 13}, {8, 11}, {9, 12}, {5, 14}, {2, 11}}}, {EdgeStyle -> { Thickness[Large]}, VertexSize -> {Medium}, VertexCoordinates -> CompressedData[" 1:eJxTTMoPSmViYGAQAWIQjR98sEcTcEDlcqDxBRyw64Px0WkGNPUcaHyYeej2 outjQFfngOY+B1Tz0N2Nbi+6Pg4ctIADALZTEnE= "]}]], Typeset`boxes = GraphicsGroupBox[{{ Directive[ Hue[0.6, 0.2, 0.8], EdgeForm[ Directive[ GrayLevel[0], Opacity[0.7]]]], TagBox[ DiskBox[{0., 0.}, 0.1], "DynamicName", BoxID -> "VertexID$1"], TagBox[ DiskBox[{0., 1.}, 0.1], "DynamicName", BoxID -> "VertexID$2"], TagBox[ DiskBox[{0., 2.}, 0.1], "DynamicName", BoxID -> "VertexID$3"], TagBox[ DiskBox[{0., 3.}, 0.1], "DynamicName", BoxID -> "VertexID$4"], TagBox[ DiskBox[{0., 4.}, 0.1], "DynamicName", BoxID -> "VertexID$5"], TagBox[ DiskBox[{1., 0.}, 0.1], "DynamicName", BoxID -> "VertexID$6"], TagBox[ DiskBox[{1., 1.}, 0.1], "DynamicName", BoxID -> "VertexID$7"], TagBox[ DiskBox[{1., 2.}, 0.1], "DynamicName", BoxID -> "VertexID$8"], TagBox[ DiskBox[{1., 3.}, 0.1], "DynamicName", BoxID -> "VertexID$9"], TagBox[ DiskBox[{1., 4.}, 0.1], "DynamicName", BoxID -> "VertexID$10"], TagBox[ DiskBox[{2., 0.}, 0.1], "DynamicName", BoxID -> "VertexID$11"], TagBox[ DiskBox[{2., 1.}, 0.1], "DynamicName", BoxID -> "VertexID$12"], TagBox[ DiskBox[{2., 2.}, 0.1], "DynamicName", BoxID -> "VertexID$13"], TagBox[ DiskBox[{2., 3.}, 0.1], "DynamicName", BoxID -> "VertexID$14"], TagBox[ DiskBox[{2., 4.}, 0.1], "DynamicName", BoxID -> "VertexID$15"], TagBox[ DiskBox[{3., 0.}, 0.1], "DynamicName", BoxID -> "VertexID$16"], TagBox[ DiskBox[{3., 1.}, 0.1], "DynamicName", BoxID -> "VertexID$17"], TagBox[ DiskBox[{3., 2.}, 0.1], "DynamicName", BoxID -> "VertexID$18"], TagBox[ DiskBox[{3., 3.}, 0.1], "DynamicName", BoxID -> "VertexID$19"], TagBox[ DiskBox[{3., 4.}, 0.1], "DynamicName", BoxID -> "VertexID$20"]}, { Directive[ Opacity[0.7], Hue[0.6, 0.7, 0.5]], Thickness[Large], StyleBox[ LineBox[{ DynamicLocation["VertexID$1", Automatic, Center], DynamicLocation["VertexID$8", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$2", Automatic, Center], DynamicLocation["VertexID$11", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$3", Automatic, Center], DynamicLocation["VertexID$10", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$13", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$7", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$4", Automatic, Center], DynamicLocation["VertexID$15", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$5", Automatic, Center], DynamicLocation["VertexID$14", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$6", Automatic, Center], DynamicLocation["VertexID$13", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$7", Automatic, Center], DynamicLocation["VertexID$16", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$8", Automatic, Center], DynamicLocation["VertexID$15", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$8", Automatic, Center], DynamicLocation["VertexID$17", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$8", Automatic, Center], DynamicLocation["VertexID$11", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$9", Automatic, Center], DynamicLocation["VertexID$18", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$9", Automatic, Center], DynamicLocation["VertexID$12", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$10", Automatic, Center], DynamicLocation["VertexID$13", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$10", Automatic, Center], DynamicLocation["VertexID$19", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$12", Automatic, Center], DynamicLocation["VertexID$19", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$13", Automatic, Center], DynamicLocation["VertexID$16", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$13", Automatic, Center], DynamicLocation["VertexID$20", Automatic, Center]}], Thickness[Large], StripOnInput -> False], StyleBox[ LineBox[{ DynamicLocation["VertexID$15", Automatic, Center], DynamicLocation["VertexID$18", Automatic, Center]}], Thickness[Large], StripOnInput -> False]}}]}, DynamicBox[GraphComputation`NetworkGraphicsBox[ 1, Typeset`graph, Typeset`boxes], { CachedValue :> Typeset`boxes, SingleEvaluation -> True, SynchronousUpdating -> False, TrackedSymbols :> {}}, ImageSizeCache->{{2.1281823783117684`, 154.2809365372767}, {-101.99694491682071`, 97.07854491682069}}]]], DefaultBaseStyle->{ "NetworkGraphics", FrontEnd`GraphicsHighlightColor -> Hue[0.8, 1., 0.6]}, FrameTicks->None, ImageSize->{157.40911891558844`, Automatic}]\);
In[2]:=
X
text[s_] := Style[s, 11, FontFamily -> "Verdana"]
In[3]:=
X
Row[{g, Grid[{ {text["Vertex count: "], ToString[VertexCount[g]]}, {text["Edge count: "], ToString[EdgeCount[g]]}, {text["Directed: "], ToString[DirectedGraphQ[g]]}, {text["Simple: "], ToString[SimpleGraphQ[g]]}, {text["Weighted: "], ToString[WeightedGraphQ[g]]}, {text["Acyclic: "], ToString[AcyclicGraphQ[g]]}, {text["Connected: "], ToString[ConnectedGraphQ[g]]}, {text["Number of components: "], ToString@Length[ConnectedComponents[g]]}, {text["Bipartite: "], ToString[BipartiteGraphQ[g]]}, {text["Eulerian: "], ToString[EulerianGraphQ[g]]}, {text["Clique number: "], ToString[Length@FindClique[g][[1]]]}, {text["Matching number: "], ToString[Length@FindIndependentEdgeSet[g]]}, {text["Edge cover number: "], ToString[Length@FindEdgeCover[g]]}, {text["Size of maximum independent set: "], ToString[Length@FindIndependentVertexSet[g]]}, {text["Vertex cover number: "], ToString[Length@FindVertexCover[g]]}, {text["K-core number: "], ToString[ Module[{i = 1}, While[KCoreComponents[g, i] != {}, ++i]; i - 1]]}}, Alignment -> Left]}, Spacer[20]]
Out[3]=