Subgraph
✖
Subgraph
gives the subgraph generated by the vertices and edges that match the pattern patt.
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 allBasic Examples (1)Summary of the most common use cases
Scope (7)Survey of the scope of standard use cases
Subgraph works with undirected graphs:

https://wolfram.com/xid/0i1ivd2li-bve1eo


https://wolfram.com/xid/0i1ivd2li-hwrlf


https://wolfram.com/xid/0i1ivd2li-2v2f3n


https://wolfram.com/xid/0i1ivd2li-rlhrjj

Use rules to specify the graph:

https://wolfram.com/xid/0i1ivd2li-bndh30

Use patterns to select subgraphs:

https://wolfram.com/xid/0i1ivd2li-fa2kiq

Find the subgraph with edges that are incident to 3:

https://wolfram.com/xid/0i1ivd2li-o3ool

Find the subgraph with vertices less than 6:

https://wolfram.com/xid/0i1ivd2li-nnrbyh

Subgraph works with large graphs:

https://wolfram.com/xid/0i1ivd2li-m1lxo0

https://wolfram.com/xid/0i1ivd2li-d43fon

Applications (2)Sample problems that can be solved with this function
Select random subgraphs of size 5:

https://wolfram.com/xid/0i1ivd2li-bqfd1v

https://wolfram.com/xid/0i1ivd2li-sme60

https://wolfram.com/xid/0i1ivd2li-g2hnyv

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

https://wolfram.com/xid/0i1ivd2li-d3gpe0

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

https://wolfram.com/xid/0i1ivd2li-en6144
Select the subgraphs that are isomorphic to h:

https://wolfram.com/xid/0i1ivd2li-8f97t

https://wolfram.com/xid/0i1ivd2li-jvem9p

Properties & Relations (3)Properties of the function, and connections to other functions
The vertices of subgraphs are subsets of the original vertices:

https://wolfram.com/xid/0i1ivd2li-jzr4k


https://wolfram.com/xid/0i1ivd2li-dhc7u6

The edges of subgraphs are subsets of the original edges:

https://wolfram.com/xid/0i1ivd2li-cdkv6


https://wolfram.com/xid/0i1ivd2li-nh3u1e

The subgraph of a complete graph is a complete graph:

https://wolfram.com/xid/0i1ivd2li-hh7eio


https://wolfram.com/xid/0i1ivd2li-hctfgd


https://wolfram.com/xid/0i1ivd2li-dbg0j0

Wolfram Research (2010), Subgraph, Wolfram Language function, https://reference.wolfram.com/language/ref/Subgraph.html (updated 2015).
Text
Wolfram Research (2010), Subgraph, Wolfram Language function, https://reference.wolfram.com/language/ref/Subgraph.html (updated 2015).
Wolfram Research (2010), Subgraph, Wolfram Language function, https://reference.wolfram.com/language/ref/Subgraph.html (updated 2015).
CMS
Wolfram Language. 2010. "Subgraph." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/Subgraph.html.
Wolfram Language. 2010. "Subgraph." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/Subgraph.html.
APA
Wolfram Language. (2010). Subgraph. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Subgraph.html
Wolfram Language. (2010). Subgraph. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Subgraph.html
BibTeX
@misc{reference.wolfram_2025_subgraph, author="Wolfram Research", title="{Subgraph}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/Subgraph.html}", note=[Accessed: 24-May-2025
]}
BibLaTeX
@online{reference.wolfram_2025_subgraph, organization={Wolfram Research}, title={Subgraph}, year={2015}, url={https://reference.wolfram.com/language/ref/Subgraph.html}, note=[Accessed: 24-May-2025
]}