WLJS LogoWLJS Notebook

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.

Examples

Extract a subgraph:

g = CompleteGraph[5];
Subgraph[g, {1, 2, 3}]

Subgraph by edges:

Subgraph[CycleGraph[6], {1 <-> 2, 2 <-> 3}]

Please visit the official Wolfram Language Reference for more details.

On this page