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:

Highlight the subgraph within the main graph:

Scope  (7)

Subgraph works with undirected graphs:

Directed graphs:

Multigraph:

Mixed graph:

Use rules to specify the graph:

Use patterns to select subgraphs:

Find the subgraph with edges that are incident to 3:

Find the subgraph with vertices less than 6:

Subgraph works with large graphs:

Applications  (2)

Select random subgraphs of size 5:

Find all the subgraphs of the graph g that are isomorphic to the graph h:

Enumerate all subsets of vertices that have the same number of vertices as h:

Select the subgraphs that are isomorphic to h:

Highlight them:

Properties & Relations  (3)

The vertices of subgraphs are subsets of the original vertices:

The edges of subgraphs are subsets of the original edges:

The subgraph of a complete graph is a complete graph:

Neat Examples  (1)

Subtract random neighborhoods from a grid:

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