({{, (RefLink[SimpleGraph, paclet:ref/SimpleGraph])[g] 
gives the underlying simple graph from the graph g.}, {, (RefLink[SimpleGraph, paclet:ref/SimpleGraph])[{v->w,…}]
uses rules v->w to specify the graph g.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[SimpleGraph, paclet:ref/SimpleGraph])[g] removes all self-loops and multiple edges between the same vertices.

(RefLink[SimpleGraph, paclet:ref/SimpleGraph]) preserves directed edges as directed. (RefLink[UndirectedGraph, paclet:ref/UndirectedGraph]) can be used to compute the underlying undirected graph.

(RefLink[SimpleGraph, paclet:ref/SimpleGraph]) works with undirected graphs, directed graphs, multigraphs, and mixed graphs.

OpenersPrimaryExamplesSection(Spacer1)Examples  (14)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Remove self-loops from a graph:

SimpleGraph[]

OpenersExampleSection1(Spacer1)Scope  (6)

(RefLink[SimpleGraph, paclet:ref/SimpleGraph]) works with undirected graphs:

SimpleGraph[]

Directed graphs:

SimpleGraph[]

Multigraph:

SimpleGraph[]

Mixed graph:

SimpleGraph[]

Use rules to specify the graph:

SimpleGraph[{1->2,2->3,3->1,1->1}]

(RefLink[SimpleGraph, paclet:ref/SimpleGraph]) works with large graphs:

g=AdjacencyGraph[SparseArray[{{i_,i_}->1,{i_,j_}/;j==i+1->1},{10^6,10^6}]];

Timing[h=SimpleGraph[g];]

SimpleGraphQ/@{g,h}

EdgeCount/@{g,h}

OpenersExampleSection4(Spacer1)Properties & Relations  (7)

A graph with self-loops is not simple:

Graph[{1\[DirectedEdge]2,2\[DirectedEdge]3,3\[DirectedEdge]1,1\[DirectedEdge]1}]

{SimpleGraphQ[%],LoopFreeGraphQ[%]}

A (RefLink[PathGraph, paclet:ref/PathGraph]) is always simple:

g=PathGraph[Range[20]]

{PathGraphQ[g],SimpleGraphQ [g]}

A (RefLink[TreeGraph, paclet:ref/TreeGraph]) without multiple edges is simple:

g=CompleteKaryTree[3,3]

{TreeGraphQ[g],SimpleGraphQ [g]}

The adjacency matrix of a simple graph has entries not greater than 1:

g=CycleGraph[4]

SimpleGraphQ[g]

(m=AdjacencyMatrix[g])//MatrixForm

Diagonal elements are all zeros:

Diagonal[m]//Normal

The incidence matrix of a simple graph has entries -1, 0, or 1 and no repeated column:

g=Graph[{1\[DirectedEdge]2,2\[DirectedEdge]3,3\[DirectedEdge]1}]

IncidenceMatrix[g]//MatrixForm

All vertices of a simple graph have a maximum degree less than the number of vertices:

g=WheelGraph[6]

SimpleGraphQ[g]

Max[VertexDegree[g]]<VertexCount[g]

A nontrivial simple graph must have at least one pair of vertices with the same degree:

g=GridGraph[{2,3}]

SimpleGraphQ[g]

VertexDegree[g]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[SimpleGraphQ, paclet:ref/SimpleGraphQ])  ▪  (RefLink[UndirectedGraph, paclet:ref/UndirectedGraph])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Graph Operations and Modifications, paclet:guide/GraphModifications])}})}})