This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Subgraph

Subgraph
gives the subgraph of the graph g generated by the vertices .
Subgraph
gives the subgraph generated by the edges .
Subgraph
gives the subgraph generated by the vertices and edges that match the pattern patt.
  • The subgraph generated by the vertices includes the vertices and all edges connecting them in the original graph g.
  • The subgraph generated by the edges includes the edges and all vertices they are connected to in the original graph g.
Give a subgraph of a complete graph:
Highlight the subgraph within the main graph:
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]=
Subgraph works with undirected graphs:
Directed graphs:
Use patterns to select subgraphs:
Find the subgraph with edges that are incident to 3:
Find the subgraph with vertices less than 6:
Works with large graphs:
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:
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:
Subtract random neighborhoods from a grid:
New in 8