Planar Graph

Author

Eric W. Weisstein
October 12, 2011

This notebook downloaded from http://www.ericweisstein.com.

For more information, see Eric's none entry http://www.ericweisstein.com.

©2011 Wolfram Research, Inc. except for portions noted otherwise

Usage

?Planar*

Counts

Should be 1, 2, 4, 11, 33, 142, 822, 6966, 79853, ... (Sloane's A005470)

Length/@PlanarGraphs/@Range[9]

Combinatorica

Count[#,_?PlanarQ]&/@Graphs/@Range[9]//Timing

V9

Count[#,_?PlanarGraphQ]&/@Graphs/@Range[8]//Timing

Count[#,_?PlanarGraphQ]&/@Graphs/@Range[9]//Timing

Checks

V9

Monitor[If[PlanarGraphQ[GraphData[g=#]]=!=GraphData[#,"Planar"],Print[#]]&/@GraphData[All],g];//Timing

Graphs

Simple

V5.2

planar=Table[PlanarGraphs[n],{n,4}];

ShowGraphArray[Flatten[Partition[#,6,6,{1,1},{}]&/@planar,1],
VertexStyle->Disk[.13],
VertexColor->Red,
GraphicsSpacing->{.5,.4}]

V6

GraphicsGrid[MapIndexed[
GraphPlot[#1,Method->If[#2=={5,5},"RadialDrawing",Automatic]]&,Flatten[Partition[#,6,6,{1,1},{}]&/@PlanarGraphs/@Range[4],1],{2}],Spacings->100]

Connected

GraphicsGrid[MapIndexed[
GraphPlot[#1,Method->If[#2=={4,6},"RadialDrawing",Automatic]]&,Flatten[Partition[#,6,6,{1,1},{}]&/@PlanarConnectedGraphs/@Range[4],1],{2}],Spacings->100]

Planar graph vs. Planar embedding

GraphicsArray[GraphData["K4","AllImages"]]

Mathematica embedding

{“SelfComplementary”,{8,6}}

GraphData[g1={"SelfComplementary",{8,6}},"LabeledImage"]

ShowLabeledGraph@ChangeVertices[Graph[{"SelfComplementary",{8,6}}],emb2={{3/2,1/2},{1,0},{0,1},{2,1},{0,0},{2,0},{1,1},{1/2,1/2}}]

v=SetProperty[GraphData[{"SelfComplementary",{8,6}}],GraphLayout->"PlanarEmbedding"]//GraphEmbedding

GraphPlot[GraphData[{"SelfComplementary",{8,6}},"EdgeRules"],VertexCoordinateRules->Thread[Range[8]->v]]

g=;

//InputForm

{{0.,0.},{3.4747725887883014,1.1539514058147464},{1.748716051532036,1.8147251479804858},{6.930498128481894,-0.01332912604457448},{0.0049508182451254434,6.604029748433142},{3.508541521587746,3.445478434018094},{5.038183865772982,4.77743895804317},{6.890040150591921,6.665890494428966}}/6.890040150591921

ShowLabeledGraph@(g=Graph[List/@{{1,4},{4,8},{5,8},{1,5},{5,6},{4,6},{6,7},{7,8},{3,6},{1,3},{2,3},{2,4},{1,2},{5,7}},List/@(v={{0,0},{1/2,1/6},{1/4,1/4},{1,0},{0,1},{1/2,1/2},{3/4,3/4},{1,1}})])

Solve[y-0==((1/4-0)/(1/4-1))(x-1)&&x==1/2,y]

((1/4-0)/(1/4-1))

Solve[y==-(1/3)(x-1)&&x==(1/2),y]

Solve[y==-(1/3)(x-1)&&x==(1/2),{x,y}]

Reduce[y==-(1/3)(x-1)&&x==(1/2),y]

Solve[y==-(1/3)(1/2-1),y]

RecognizeGraph[g]

emb1=ToCommonEdges[g,Graph[g1]]

emb={emb1,emb2}

{“SelfComplementary”,{8,10}}

GraphData[g1={"SelfComplementary",{8,10}},"LabeledImage"]

GraphData[g1,"Image"]

ShowLabeledGraph@ChangeVertices[Graph[g1],emb2={{1,2/3},{0,2/3},{1/2,0},{1/2,1},{1,1/3},{0,1/3},{1/3,2/3},{2/3,1/3}}]

SetProperty[GraphData[g1],GraphLayout->"PlanarEmbedding"]

v=GraphEmbedding[%]

GraphPlot[GraphData[g1,"EdgeRules"],VertexCoordinateRules->Thread[Range[8]->v]]

g=;

g//InputForm

{{0.,0.},{7.,0.},{0.,7.},{2.150398785689415,2.13868819637883},{4.6922876044568245,2.0339593488857926},{4.620631310933147,4.488958587221449},{2.0741371431058497,4.5085714441155975},{6.985027855153203,6.965349712743732}}/6.965349712743732

ShowLabeledGraph@(g=Graph[List/@{{1,2},{2,8},{3,8},{1,3},{3,7},{6,7},{6,8},{2,5},{1,4},{7,8},{2,4},{4,7},{5,6},{4,5}},List/@(v={{0,0},{1,0},{0,1},{1/3,1/3},{2/3,1/3},{2/3,2/3},{1/3,2/3},{1,1}})])

RecognizeGraph[g]

emb1=ToCommonEdges[g,Graph[g1]]

emb={emb1,emb2}

Bug

Combinatorica V1 (for V4.0)

This graph is not actually planar!

PlanarQ[Graph[{{0,0,0,1,1,1},{0,0,0,1,1,1},{0,0,0,1,1,1},{1,1,1,0,1,1},{1,1,1,1,0,1},{1,1,1,1,1,0}},{{1.,0.},{0.5,0.8660254037844386},{-0.5,0.8660254037844386},{-1.,0.},{-0.5,-0.8660254037844386},{0.5,-0.8660254037844386}}]]

Fixed in 4.1

PlanarQ[Graph[{{0,0,0,1,1,1},{0,0,0,1,1,1},{0,0,0,1,1,1},{1,1,1,0,1,1},{1,1,1,1,0,1},{1,1,1,1,1,0}},{{1.,0.},{0.5,0.8660254037844386},{-0.5,0.8660254037844386},{-1.,0.},{-0.5,-0.8660254037844386},{0.5,-0.8660254037844386}}]]

Combinatorica 2

<<"/Volumes/Data/Mathematica/OtherPackages/Combinatorica/NewCombinatorica.m"

m={{0,0,0,1,1,1},{0,0,0,1,1,1},{0,0,0,1,1,1},{1,1,1,0,1,1},{1,1,1,1,0,1},{1,1,1,1,1,0}};

PlanarQ[FromAdjacencyMatrix[m]]

Planar with minimum valency k

Planar with minimum valency ≥ 2

Length/@(v2=Select[PlanarGraphs[#],Min[Degrees[#]]≥2&]&/@Range[9])//Timing

Off[General::"stop"]

ShowGraphArray[
Map[RecognizeGraph,
Flatten[Partition[#,5,5,{1,1},{}]&/@Take[v2,5],1],
{2}],
VertexStyle->Disk[.15]
]

Planar with minimum valency ≥ 3

Length/@(v3=Select[v2[[#]],Min[Degrees[#]]≥3&]&/@Range[9])//Timing

Off[General::"stop"]

ShowGraphArray[
Map[RecognizeGraph,
Flatten[Partition[#,5,5,{1,1},{}]&/@Take[v3,6],1],
{2}],
VertexStyle->Disk[.1]
]

Planar with minimum valency ≥ 4

Length/@(v4=Select[v3[[#]],Min[Degrees[#]]≥4&]&/@Range[9])//Timing

Off[General::"stop"]

ShowGraphArray[
Map[RecognizeGraph,
Flatten[Partition[#,7,7,{1,1},{}]&/@v4,1],
{2}],
VertexStyle->Disk[.1]
]

Planar with minimum valency ≥ 5

Length/@(v5=Select[v4[[#]],Min[Degrees[#]]≥5&]&/@Range[9])//Timing