Subgraph

Subgraph[g,{v1,v2,}]

gives the subgraph of the graph g generated by the vertices vi.

Subgraph[g,{e1,e2,}]

gives the subgraph generated by the edges ej.

Subgraph[g,patt]

gives the subgraph generated by the vertices and edges that match the pattern patt.

Subgraph[{vw,},]

uses rules vw to specify the graph g.

Details and Options

  • The subgraph generated by the vertices v1,v2, includes the vertices vi and all edges connecting them in the original graph g.
  • The subgraph generated by the edges e1,e2, includes the edges ej and all edges connecting vertices vi of ej in the original graph g.
  • Subgraph works with undirected graphs, directed graphs, multigraphs, and mixed graphs.

Examples

open allclose all

Basic Examples  (1)

Give a subgraph of a complete graph:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

Highlight the subgraph within the main graph:

In[3]:=
Click for copyable input
Out[3]=

Scope  (7)

Applications  (2)

Properties & Relations  (3)

Neat Examples  (1)

See Also

Graph  DirectedGraph  TreeGraph  PathGraph

Introduced in 2010
(8.0)
| Updated in 2015
(10.3)