({{, (RefLink[CompleteGraph, paclet:ref/CompleteGraph])[n] 
gives the complete graph with n vertices (Subscript[K, n]).}, {, (RefLink[CompleteGraph, paclet:ref/CompleteGraph])[{(Subscript[n, 1]),(Subscript[n, 2]),…,(Subscript[n, k])}]
gives the complete k-partite graph with (Subscript[n, 1])+(Subscript[n, 2])+⋯+(Subscript[n, k]) vertices (Subscript[K, (Subscript[n, 1]),(Subscript[n, 2]),…,(Subscript[n, k])]).}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[CompleteGraph, paclet:ref/CompleteGraph]) generates a (RefLink[Graph, paclet:ref/Graph]) object.

(RefLink[CompleteGraph, paclet:ref/CompleteGraph])[n] gives a graph with n vertices and an edge between every pair of vertices.

(RefLink[CompleteGraph, paclet:ref/CompleteGraph])[{(Subscript[n, 1]),(Subscript[n, 2]),…,(Subscript[n, k])}] gives a graph with (Subscript[n, 1])+⋯+(Subscript[n, k]) vertices partitioned into disjoint sets (Subscript[V, i]) with (Subscript[n, i]) vertices each and edges between all vertices in different sets (Subscript[V, i]) and (Subscript[V, j]), but no edges between vertices in the same set (Subscript[V, i]).

(RefLink[CompleteGraph, paclet:ref/CompleteGraph])[…,(RefLink[DirectedEdges, paclet:ref/DirectedEdges])->(RefLink[True, paclet:ref/True])] gives a directed complete graph.

(RefLink[CompleteGraph, paclet:ref/CompleteGraph]) takes the same options as (RefLink[Graph, paclet:ref/Graph]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (106)

OpenersExampleSection0(Spacer1)Basic Examples  (4)

The first few complete graphs (Subscript[K, i]):

Table[CompleteGraph[i,PlotLabel->(Subscript[K, i])],{i,3,6}]

Bipartite graphs (Subscript[K, i,i]):

Table[CompleteGraph[{i,i},PlotLabel->(Subscript[K, i,i])],{i,2,4}]

Directed complete graphs use two directional edges for each undirected edge:

Table[CompleteGraph[n,DirectedEdges->True,PlotLabel->(Subscript[K, n])],{n,3,5}]

Directed complete k-partite graphs use directed edges from one group to another:

Table[CompleteGraph[{i,i,i},DirectedEdges->True,PlotLabel->(Subscript[K, i,i,i])],{i,2,4}]

OpenersExampleSection1(Spacer1)Options  (81)

OpenersExampleSubsection0(Spacer1)DirectedEdges  (2)

By default, an undirected graph is generated:

CompleteGraph[4]

Use (RefLink[DirectedEdges, paclet:ref/DirectedEdges])->(RefLink[True, paclet:ref/True]) to generate a directed graph:

CompleteGraph[4,DirectedEdges->True]

Generate directed k-partite graphs:

Row[Table[CompleteGraph[Range[n],DirectedEdges->True],{n,2,4}]]

OpenersExampleSubsection1(Spacer1)EdgeLabels  (7)

Label the edge 1<->2:

CompleteGraph[4,EdgeLabels->{1\[UndirectedEdge]2->"Hello"}]

Label all edges individually:

el=EdgeList[CompleteGraph[4]]

CompleteGraph[4,EdgeLabels->Table[el[[i]]->(Subscript["e", i]),{i,Length[el]}]]

Use any expression as a label:

CompleteGraph[4,EdgeLabels->{2\[UndirectedEdge]4->,3\[UndirectedEdge]4->,1\[UndirectedEdge]3-> }]

Use (RefLink[Placed, paclet:ref/Placed]) with symbolic locations to control label placement along an edge:

Table[CompleteGraph[4,EdgeLabels->{3\[UndirectedEdge]4->Placed["■■■",p]},PlotLabel->p],{p,{"Start","Middle","End"}}]

Use explicit coordinates to place labels:

Table[CompleteGraph[4,EdgeLabels->{2\[UndirectedEdge]3->Placed["■■■",p]},PlotLabel->p,BaselinePosition->Bottom],{p,{0,1/4,1/3}}]

Vary positions within the label:

Table[CompleteGraph[4,EdgeLabels->{2\[UndirectedEdge]3->Placed["■■■",{1/2,p}]},PlotLabel->p,BaselinePosition->Bottom],{p,{{0,0},{1/2,1/2},{1,1}}}]

Place multiple labels:

CompleteGraph[5,EdgeLabels->{3\[UndirectedEdge]1->Placed[{"lbl1","lbl2"},{"Start","End"}]}]

CompleteGraph[5,EdgeLabels->{3\[UndirectedEdge]1->Placed[{"lbl1","lbl2","lbl3"},{"Start","Middle","End"}]}]

Use automatic labeling by values through (RefLink[Tooltip, paclet:ref/Tooltip]) and (RefLink[StatusArea, paclet:ref/StatusArea]):

CompleteGraph[5,EdgeLabels->Placed["Name",Tooltip]]

CompleteGraph[5,EdgeLabels->Placed["Name",StatusArea]]

OpenersExampleSubsection2(Spacer1)EdgeShapeFunction  (6)

Get a list of built-in settings for (RefLink[EdgeShapeFunction, paclet:ref/EdgeShapeFunction]):

GraphElementData["Edge"]

Undirected edges including the basic line:

CompleteGraph[4,EdgeShapeFunction->"Line"]

Lines with different glyphs on the edges:

Table[CompleteGraph[4,EdgeShapeFunction->GraphElementData[ef,"ArrowSize"->0.1],PlotLabel->ef],{ef,{"BoxLine","DiamondLine","DotLine"}}]

Directed edges including solid arrows:

Table[CompleteGraph[4,EdgeShapeFunction->GraphElementData[ef,"ArrowSize"->0.1],PlotLabel->ef],{ef,GraphElementData["Edge","FilledArrow"]}]

Line arrows:

Table[CompleteGraph[4,EdgeShapeFunction->GraphElementData[ef,"ArrowSize"->0.1],PlotLabel->ef],{ef,GraphElementData["Edge","UnfilledArrow"]}]

Open arrows:

Table[CompleteGraph[4,EdgeShapeFunction->GraphElementData[ef,"ArrowSize"->0.1],PlotLabel->ef],{ef,GraphElementData["Edge","CarvedArrow"]}]

Specify an edge function for an individual edge:

CompleteGraph[4,EdgeShapeFunction->{1\[UndirectedEdge]2->"DotLine"}]

Combine with a different default edge function:

CompleteGraph[5,EdgeShapeFunction->{1\[UndirectedEdge]2->"BoxLine","DotLine"}]

Draw edges by running a program:

ef[pts_List,e_]:=
Block[{s=0.015,g=},{Arrowheads[{{s,0.33,g},{s,0.67,g}}],Arrow[pts]}]

CompleteGraph[4,EdgeShapeFunction->ef]

(RefLink[EdgeShapeFunction, paclet:ref/EdgeShapeFunction]) can be combined with (RefLink[EdgeStyle, paclet:ref/EdgeStyle]):

CompleteGraph[4,EdgeStyle->Blue,EdgeShapeFunction->(Line[#1]&)]

(RefLink[EdgeShapeFunction, paclet:ref/EdgeShapeFunction]) has higher priority than (RefLink[EdgeStyle, paclet:ref/EdgeStyle]):

CompleteGraph[4,EdgeStyle->Blue,EdgeShapeFunction->({Red,Line[#1]}&)]

OpenersExampleSubsection3(Spacer1)EdgeStyle  (2)

Style all edges:

Table[CompleteGraph[4,EdgeStyle->style,PlotLabel->style],{style,{Gray,Dashed,Thick}}]

Style individual edges:

CompleteGraph[4,EdgeStyle->{1\[UndirectedEdge]2->Blue,1\[UndirectedEdge]3->Dashed}]

OpenersExampleSubsection4(Spacer1)EdgeWeight  (2)

Specify a weight for all edges:

CompleteGraph[4,EdgeWeight->RandomInteger[5,6]]

WeightedAdjacencyMatrix[%]//MatrixForm

Use any numeric expression as a weight:

CompleteGraph[4,EdgeWeight->{a,b,c,d,e,f}]

WeightedAdjacencyMatrix[%]//MatrixForm

OpenersExampleSubsection5(Spacer1)GraphHighlight  (3)

Highlight the vertex 1:

CompleteGraph[4,VertexSize->Tiny,GraphHighlight->{1}]

Highlight the edge 2<->3:

CompleteGraph[4,VertexSize->Tiny,GraphHighlight->{2\[UndirectedEdge]3}]

Highlight the vertices and edges:

CompleteGraph[4,VertexSize->Tiny,GraphHighlight->{1,2,1\[UndirectedEdge]3,2\[UndirectedEdge]3}]

OpenersExampleSubsection6(Spacer1)GraphHighlightStyle  (2)

Get a list of built-in settings for (RefLink[GraphHighlightStyle, paclet:ref/GraphHighlightStyle]):

GraphElementData["GraphHighlightStyle"]

Use built-in settings for (RefLink[GraphHighlightStyle, paclet:ref/GraphHighlightStyle]):

CompleteGraph[3,GraphHighlight->{1,2\[UndirectedEdge]3},VertexSize->Small,GraphHighlightStyle->#,PlotLabel->#]&/@Select[GraphElementData["GraphHighlightStyle"],#=!=Automatic&]

OpenersExampleSubsection7(Spacer1)GraphLayout  (5)

By default, the layout is chosen automatically:

CompleteGraph[5,GraphLayout->Automatic]

Specify layouts on special curves:

Table[CompleteGraph[20,GraphLayout->l,PlotLabel->l],{l,{"CircularEmbedding","SpiralEmbedding"}}]

Specify layouts that satisfy optimality criteria:

Table[CompleteGraph[20,GraphLayout->l,PlotLabel->l],{l,{"SpringEmbedding","SpringElectricalEmbedding","HighDimensionalEmbedding"}}]

(RefLink[VertexCoordinates, paclet:ref/VertexCoordinates]) overrides (RefLink[GraphLayout, paclet:ref/GraphLayout]) coordinates:

{CompleteGraph[5,GraphLayout->"SpringElectricalEmbedding"],
CompleteGraph[5,GraphLayout->"SpringElectricalEmbedding",VertexCoordinates->Table[{i,i},{i,0,4}]]}

Use (RefLink[AbsoluteOptions, paclet:ref/AbsoluteOptions]) to extract (RefLink[VertexCoordinates, paclet:ref/VertexCoordinates]) computed using a layout algorithm:

CompleteGraph[5]

AbsoluteOptions[%,VertexCoordinates]

OpenersExampleSubsection8(Spacer1)PlotTheme  (4)

OpenersExampleSubsubsection0(Spacer1)Base Themes  (2)

Use a common base theme:

CompleteGraph[4,PlotTheme->"Business"]

Use a monochrome theme:

CompleteGraph[4,PlotTheme->"Monochrome"]

OpenersExampleSubsubsection1(Spacer1)Feature Themes  (2)

Use a large graph theme:

CompleteGraph[4,PlotTheme->"LargeGraph"]

Use a classic diagram theme:

CompleteGraph[4,PlotTheme->"ClassicDiagram"]

OpenersExampleSubsection9(Spacer1)Properties  (2)

Specify a property for vertices:

CompleteGraph[4,Properties->{1->{VertexLabels-> "hello"}}]

Edges:

CompleteGraph[4,Properties->{1\[UndirectedEdge]2->{EdgeLabels-> "hello"}}]

OpenersExampleSubsection10(Spacer1)VertexCoordinates  (3)

By default, any vertex coordinates are computed automatically:

CompleteGraph[4]

Extract the resulting vertex coordinates using (RefLink[AbsoluteOptions, paclet:ref/AbsoluteOptions]):

AbsoluteOptions[%,VertexCoordinates]

Specify a layout function along an ellipse:

ellipseLayout[n_,{a_,b_}]:=Table[{a Cos[2Pi/n u],b Sin[2Pi/n u]},{u,1,n}]

Graphics[Point[ellipseLayout[10,{2,1}]]]

Use it to generate vertex coordinates for a graph:

CompleteGraph[10,VertexCoordinates->ellipseLayout[10,{2,1}]]

(RefLink[VertexCoordinates, paclet:ref/VertexCoordinates]) has higher priority than (RefLink[GraphLayout, paclet:ref/GraphLayout]):

CompleteGraph[4,VertexCoordinates->Table[{i,i},{i,4}],GraphLayout->"CircularEmbedding"]

OpenersExampleSubsection11(Spacer1)VertexLabels  (13)

Use vertex names as labels:

CompleteGraph[3,VertexLabels->"Name"]

Label individual vertices:

CompleteGraph[3,VertexLabels->{1->"one"}]

Label all vertices:

CompleteGraph[3,VertexLabels->Table[i->(Subscript[v, i]),{i,3}]]

Use any expression as a label:

CompleteGraph[3,VertexLabels->{1->,2->,3->},ImagePadding->20]

Use (RefLink[Placed, paclet:ref/Placed]) with symbolic locations to control label placement, including outside positions:

Table[CompleteGraph[3,VertexSize->0.1,VertexShapeFunction->"Square",VertexLabels->Table[i->Placed["■■■",p],{i,3}],PlotLabel->p,ImagePadding->20],{p,{Before,After,Below,Above}}]

Symbolic outside corner positions:

pl={{Before,Below},{After,Below},{Before,Above},{After,Above}};

Table[CompleteGraph[3,VertexSize->0.1,VertexShapeFunction->"Square",ImagePadding->20,VertexLabels->Table[i->Placed["■■■",p],{i,3}],PlotLabel->p],{p,pl}]

Symbolic inside positions:

Table[CompleteGraph[3,VertexSize->0.25,VertexLabels->Table[i->Placed["■■■",p],{i,3}],VertexShapeFunction->"Square",PlotLabel->p],{p,{Left,Top,Right,Bottom}}]

Symbolic inside corner positions:

pl={{Left,Bottom},{Right,Bottom},{Left,Top},{Right,Top}};

Table[CompleteGraph[3,VertexSize->0.25,VertexShapeFunction->"Square",VertexLabels->Table[i->Placed["■■■",p],{i,3}],PlotLabel->p],{p,pl}]

Use explicit coordinates to place the center of labels:

Table[CompleteGraph[3,VertexSize->0.25,VertexShapeFunction->"Square",VertexLabels->Table[i->Placed[,p],{i,3}],PlotLabel->p,BaselinePosition->Bottom],{p,{{0,0},{1/2,1/2},{1,1}}}]

Place all labels at the upper-right corner of the vertex and vary the coordinates within the label:

Table[CompleteGraph[3,VertexSize->0.35,VertexShapeFunction->"Square",VertexLabels->Table[i->Placed[,{{1,1},p}],{i,3}],PlotLabel->p,BaselinePosition->Bottom],{p,{{0,0},{1/2,1/2},{1,1}}}]

Place multiple labels:

CompleteGraph[3,VertexLabels->{1->Placed[{"lbl1","lbl2"},{Above,Below}]}]

Any number of labels can be used:

CompleteGraph[3,VertexLabels->{1->Placed[{"lbl1","lbl2","lbl3","lbl4"},{Above,After,Below,Before}]}]

Use the argument to (RefLink[Placed, paclet:ref/Placed]) to control formatting including (RefLink[Tooltip, paclet:ref/Tooltip]):

CompleteGraph[3,VertexLabels->Placed["Name",Tooltip]]

Or (RefLink[StatusArea, paclet:ref/StatusArea]):

CompleteGraph[3,VertexLabels->Placed["Name",StatusArea]]

Use more elaborate formatting functions:

rotateLabel[lab_]:=Rotate[lab,45Degree]

CompleteGraph[3,VertexLabels->Table[i->Placed["xxx",Below,rotateLabel],{i,3}]]

panelLabel[lab_]:=Panel[lab,FrameMargins->0,Background->Lighter[Yellow,0.7]]

CompleteGraph[3,VertexLabels->Table[i->Placed["xxx",Center,panelLabel],{i,3}]]

hyperlinkLabel[lab_]:=Hyperlink[lab,"http://www.wolfram.com"]

CompleteGraph[3,VertexLabels->Table[i->Placed["xxx",Center,hyperlinkLabel],{i,3}]]

OpenersExampleSubsection12(Spacer1)VertexShape  (5)

Use any (RefLink[Graphics, paclet:ref/Graphics]), (RefLink[Image, paclet:ref/Image]), or (RefLink[Graphics3D, paclet:ref/Graphics3D]) as a vertex shape:

Table[CompleteGraph[5,VertexShape->s,VertexSize->Medium],{s,{,,}}]

Specify vertex shapes for individual vertices:

CompleteGraph[5,VertexShape->{2->},VertexSize->Medium]

(RefLink[VertexShape, paclet:ref/VertexShape]) can be combined with (RefLink[VertexSize, paclet:ref/VertexSize]):

Table[CompleteGraph[5,VertexSize->s,VertexShape->,PlotLabel->s],{s,{Small,Large}}]

(RefLink[VertexShape, paclet:ref/VertexShape]) is not affected by (RefLink[VertexStyle, paclet:ref/VertexStyle]):

CompleteGraph[5,VertexSize->0.2,VertexShape->,VertexStyle->Blue]

(RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) has higher priority than (RefLink[VertexShape, paclet:ref/VertexShape]):

CompleteGraph[5,VertexSize->0.1,VertexShapeFunction->"Square",VertexShape->]

OpenersExampleSubsection13(Spacer1)VertexShapeFunction  (10)

Get a list of built-in collections for (RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]):

GraphElementData["Vertex"]

Use built-in settings for (RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) in the "Basic" collection:

GraphElementData["Vertex","Basic"]

Simple basic shapes:

Table[CompleteGraph[4,VertexShapeFunction->vf,VertexSize->0.2,PlotLabel->vf],{vf,{"Triangle","Square","Rectangle","Pentagon","Hexagon","Octagon"}}]

Common basic shapes:

Table[CompleteGraph[4,VertexShapeFunction->vf,VertexSize->0.2,PlotLabel->vf],{vf,{"DownTrapezoid","UpTrapezoid","Parallelogram","FiveDown","Circle","Diamond","Star","Capsule"}}]

Use built-in settings for (RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) in the "Rounded" collection:

GraphElementData["Vertex","Rounded"]

Table[CompleteGraph[4,VertexShapeFunction->vf,VertexSize->0.2,PlotLabel->vf],{vf,GraphElementData["Vertex","Rounded"]}]

Use built-in settings for (RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) in the "Concave" collection:

GraphElementData["Vertex","Concave"]

Table[CompleteGraph[4,VertexShapeFunction->vf,VertexSize->0.2,PlotLabel->vf],{vf,GraphElementData["Vertex","Concave"]}]

Draw individual vertices:

CompleteGraph[4,VertexShapeFunction->{ 1->"Square"},VertexSize->0.2]

Combine with a default vertex function:

CompleteGraph[4,VertexShapeFunction->{ 1->"Square","Triangle"},VertexSize->0.2]

Draw vertices using a predefined graphic:

CompleteGraph[4,VertexShapeFunction->(Inset[,#]&)]

Draw vertices by running a program:

vf[{xc_,yc_},name_,{w_,h_}]:=
Block[{xmin=xc-w,xmax=xc+w,ymin=yc-h,ymax=yc+h},
Polygon[{{xmin,ymin},{xmax,ymax},{xmin,ymax},{xmax,ymin}}]
];

CompleteGraph[4,VertexShapeFunction->vf,VertexSize->0.2]

(RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) can be combined with (RefLink[VertexStyle, paclet:ref/VertexStyle]):

vf1[{xc_,yc_},name_,{w_,h_}]:=Rectangle[{xc-w,yc-h},{xc+w,yc+h}]

CompleteGraph[4,VertexSize->0.2,VertexStyle->Blue,VertexShapeFunction->vf1]

(RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) has higher priority than (RefLink[VertexStyle, paclet:ref/VertexStyle]):

vf2[{xc_,yc_},name_,{w_,h_}]:={Red,Rectangle[{xc-w,yc-h},{xc+w,yc+h}]}

CompleteGraph[4,VertexSize->0.2,VertexStyle->Blue,VertexShapeFunction->vf2]

(RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) can be combined with (RefLink[VertexSize, paclet:ref/VertexSize]):

CompleteGraph[4,VertexShapeFunction->"Star",VertexSize->{1->Small,Medium}]

(RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) has higher priority than (RefLink[VertexShape, paclet:ref/VertexShape]):

CompleteGraph[4,VertexSize->0.3,VertexShapeFunction->"Star",VertexShape->]

OpenersExampleSubsection14(Spacer1)VertexSize  (8)

By default, the size of vertices is computed automatically:

CompleteGraph[5,VertexSize->Automatic]

Specify the size of all vertices using symbolic vertex size:

Table[CompleteGraph[5,VertexSize->s,PlotLabel->s],{s,{Tiny,Small,Medium,Large}}]

Use a fraction of the minimum distance between vertex coordinates:

Table[CompleteGraph[5,VertexSize->s,PlotLabel->s],{s,0.1,1,0.3}]

Use a fraction of the overall diagonal for all vertex coordinates:

Table[CompleteGraph[5,VertexSize->{"Scaled", s},PlotLabel->{"Scaled", s}],{s,0.1,1,0.3}]

Specify size in both the x and y directions:

Table[CompleteGraph[5,VertexSize->s,PlotLabel->s],{s,{{0.1,0.2},{0.2,0.1}}}]

Specify the size for individual vertices:

CompleteGraph[4,VertexSize->{1->0.2,2->0.3}]

(RefLink[VertexSize, paclet:ref/VertexSize]) can be combined with (RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]):

Table[CompleteGraph[5,VertexSize->s,VertexShapeFunction->"Square",PlotLabel->s],{s,{0.05,0.1,0.2}}]

(RefLink[VertexSize, paclet:ref/VertexSize]) can be combined with (RefLink[VertexShape, paclet:ref/VertexShape]):

Table[CompleteGraph[5,VertexSize->s,VertexShape->,PlotLabel->s],{s,{0.1,0.2,0.4}}]

OpenersExampleSubsection15(Spacer1)VertexStyle  (5)

Style all vertices:

Table[CompleteGraph[4,VertexStyle->style,VertexSize->0.3,PlotLabel->style],{style,{Yellow,EdgeForm[Dashed]}}]

Style individual vertices:

CompleteGraph[4,VertexStyle->{1->Blue,2->Red},VertexSize->0.2]

(RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) can be combined with (RefLink[VertexStyle, paclet:ref/VertexStyle]):

vf1[{xc_,yc_},name_,{w_,h_}]:=Rectangle[{xc-w,yc-h},{xc+w,yc+h}]

CompleteGraph[4,VertexSize->0.2,VertexStyle->Blue,VertexShapeFunction->vf1]

(RefLink[VertexShapeFunction, paclet:ref/VertexShapeFunction]) has higher priority than (RefLink[VertexStyle, paclet:ref/VertexStyle]):

vf2[{xc_,yc_},name_,{w_,h_}]:={Red,Rectangle[{xc-w,yc-h},{xc+w,yc+h}]}

CompleteGraph[4,VertexSize->0.2,VertexStyle->Blue,VertexShapeFunction->vf2]

(RefLink[VertexStyle, paclet:ref/VertexStyle]) can be combined with (RefLink[BaseStyle, paclet:ref/BaseStyle]):

CompleteGraph[4,VertexStyle->LightBlue,BaseStyle->EdgeForm[Dotted],VertexSize->0.2]

(RefLink[VertexStyle, paclet:ref/VertexStyle]) has higher priority than (RefLink[BaseStyle, paclet:ref/BaseStyle]):

CompleteGraph[4,VertexStyle->LightBlue,BaseStyle->Gray,VertexSize->0.2]

(RefLink[VertexShape, paclet:ref/VertexShape]) is not affected by (RefLink[VertexStyle, paclet:ref/VertexStyle]):

CompleteGraph[5,VertexSize->0.2,VertexShape->,VertexStyle->Blue]

OpenersExampleSubsection16(Spacer1)VertexWeight  (2)

Set the weight for all vertices:

CompleteGraph[3,VertexWeight->{2,3,4}]

PropertyValue[{%,1},VertexWeight]

Use any numeric expression as a weight:

CompleteGraph[3,VertexWeight->{a,b,c}]

PropertyValue[{%,1},VertexWeight]

OpenersExampleSection2(Spacer1)Applications  (7)

The (RefLink[GraphCenter, paclet:ref/GraphCenter]) of a complete graph includes all its vertices:

Table[HighlightGraph[#,GraphCenter[#]]&[CompleteGraph[i,VertexSize->Small]],{i,3,6}]

The (RefLink[GraphPeriphery, paclet:ref/GraphPeriphery]) includes all vertices:

Table[HighlightGraph[#,GraphPeriphery[#]]&[CompleteGraph[i,VertexSize->Small]],{i,3,6}]

The (RefLink[VertexEccentricity, paclet:ref/VertexEccentricity]) for all vertices is 1:

VertexEccentricity[CompleteGraph[5],#]&/@VertexList[CompleteGraph[5]]

Highlight the vertex eccentricity path:

FindVertexEccentricityPath[g_?UndirectedGraphQ,u_]/;MemberQ[VertexList[g],u]:=Module[{d=GraphDistanceMatrix[g],v,posu,posv,vl=VertexList[g]},posu=VertexIndex[g,u];
posv=First@First@Position[d[[posu]],Max[d[[posu]]]];
PathGraph[FindShortestPath[g,u,vl[[posv]]]]]

Table[HighlightGraph[g=CompleteGraph[4],FindVertexEccentricityPath[g,u]],{u,Range[4]}]

The (RefLink[GraphRadius, paclet:ref/GraphRadius]) is 1:

Table[GraphRadius[CompleteGraph[i]],{i,3,6}]

Highlight the radius path:

FindRadiusPath[g_?UndirectedGraphQ]:=Module[{c=First@GraphCenter[g],d,v,pos},d=Table[GraphDistance[g,c,u],{u,VertexList[g]}];
pos=First@Position[d,Max[d]];
v=First@Part[VertexList[g],pos];
PathGraph[FindShortestPath[g,c,v]]]

Table[HighlightGraph[#,FindRadiusPath[#]]&[CompleteGraph[i,VertexSize->Small]],{i,3,6}]

The (RefLink[GraphDiameter, paclet:ref/GraphDiameter]) is 1:

Table[GraphDiameter[CompleteGraph[i]],{i,3,6}]

Highlight the diameter path:

FindDiameterPath[g_?UndirectedGraphQ]:=Module[{d=GraphDistanceMatrix[g],u,v,pos},pos=First@Position[d,Max[d]];
{u,v}=Part[VertexList[g],pos];
PathGraph[FindShortestPath[g,u,v]]]

Table[HighlightGraph[#,FindDiameterPath[#]]&[CompleteGraph[i,VertexSize->Small]],{i,3,6}]

Vertex connectivity from s to t is the number of vertex-independent paths from s to t:

g=CompleteGraph[4,VertexLabels->"Name"]

There are 3 vertex-independent paths between any pair of vertices:

{HighlightGraph[g,1\[UndirectedEdge]2],
HighlightGraph[g,PathGraph[{1,3,2}]],
HighlightGraph[g,PathGraph[{1,4,2}]]}

The vertex connectivity for (RefLink[CompleteGraph, paclet:ref/CompleteGraph])[n] is n-1:

g=CompleteGraph[5,VertexLabels->"Name"];

{HighlightGraph[g,PathGraph[{1,2}]],
HighlightGraph[g,PathGraph[{1,3,2}]],
HighlightGraph[g,PathGraph[{1,4,2}]],
HighlightGraph[g,PathGraph[{1,5,2}]]
}

Highlight the vertex degree for (RefLink[CompleteGraph, paclet:ref/CompleteGraph]):

HighlightCentrality[g_, cc_]:=HighlightGraph[g,Table[Style[VertexList[g][[i]],ColorData["TemperatureMap"][cc[[i]]/Max[cc]]],{i,VertexCount[g]}]];

g=CompleteGraph[8,VertexSize->Large];

HighlightCentrality[g,VertexDegree[g]]

Highlight the closeness centrality:

HighlightCentrality[g,ClosenessCentrality[g]]

Highlight the eigenvector centrality:

HighlightCentrality[g,EigenvectorCentrality[g]]

OpenersExampleSection3(Spacer1)Properties & Relations  (12)

Number of vertices of (RefLink[CompleteGraph, paclet:ref/CompleteGraph])[n]:

VertexCount[CompleteGraph[n]]

Number of edges of (RefLink[CompleteGraph, paclet:ref/CompleteGraph])[n]:

EdgeCount[CompleteGraph[n]]

A complete graph is an (n-1)-regular graph:

CompleteGraph[6]

VertexDegree[%]

The subgraph of a complete graph is a complete graph:

g=CompleteGraph[8]

HighlightGraph[g,h=Subgraph[g,Range[5]]]

CompleteGraphQ[h]

The neighborhood of a vertex in a complete graph is the graph itself:

CompleteGraph[8,VertexSize->{1->0.2}]

HighlightGraph[%,NeighborhoodGraph[%,1]]

Complete graphs are their own cliques:

CompleteGraph[5]

Subgraph[%,First[FindClique[%]]]

The (RefLink[GraphComplement, paclet:ref/GraphComplement]) of a complete graph with no edges:

GraphComplement[CompleteGraph[5]]

For a complete graph, all entries outside the diagonal are 1s in the (RefLink[AdjacencyMatrix, paclet:ref/AdjacencyMatrix]):

AdjacencyMatrix[CompleteGraph[25]]//MatrixPlot

For a complete k-partite graph, all entries outside the block diagonal are 1s:

AdjacencyMatrix[CompleteGraph[{1,2,3,4,5}]]//MatrixPlot

The complete graph (Subscript[K, 3]) is the cycle graph (Subscript[C, 3]):

{CompleteGraph[3],CycleGraph[3]}

The complete graph (Subscript[K, 4]) is the wheel graph (Subscript[W, 4]):

{CompleteGraph[4],WheelGraph[4]}

The complete graph (Subscript[K, n]) is the line graph of the star graph (Subscript[S, n+1]):

{CompleteGraph[6],LineGraph[StarGraph[7]]}

OpenersExampleSection4(Spacer1)Neat Examples  (2)

Random collage of complete graphs:

Graphics[Table[Inset[CompleteGraph[RandomInteger[{4,8}]],RandomReal[{0,10},2],Automatic,1],{75}]]

Coloring cycle decompositions in complete graphs on a prime number of vertices:

ColoringCycles[n_]:=Block[{i,e},
e=Table[Mod[#,n,1]\[UndirectedEdge]Mod[#+i,n,1]&/@Range[n],{i,(n-1)/2}];
HighlightGraph[CompleteGraph[n],Table[Style[e[[i]],ColorData[1][i]],{i,Length[e]}]]
]

Table[ColoringCycles[i],{i,{3,5,7,9,11,13}}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Graph, paclet:ref/Graph])  ▪  (RefLink[GraphData, paclet:ref/GraphData])  ▪  (RefLink[GraphComplement, paclet:ref/GraphComplement])  ▪  (RefLink[CompleteGraphQ, paclet:ref/CompleteGraphQ])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Graph Construction & Representation, paclet:guide/GraphConstructionAndRepresentation])}, {▪(RefLinkPlain[Graphs & Networks, paclet:guide/GraphsAndNetworks])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/21-graphs-and-networks.html])(WebLink[: Graphs and Networks, https://www.wolfram.com/language/elementary-introduction/21-graphs-and-networks.html])}})}})