VertexInComponentGraph[g,{v1,v2,…}]
gives the subgraph of the graph g generated by the vertices that have a directed path to at least one of v1,v2,….
VertexInComponentGraph[g,{v1,v2,…},k]
gives the subgraph of g generated by vertices with a directed path of at most length k to at least one of v1,v2,….
VertexInComponentGraph[g,{v1,v2,…},{k}]
gives the subgraph of g generated by vertices of length exactly k.
VertexInComponentGraph[{vw,…},…]
uses rules vw to specify the graph g.
VertexInComponentGraph
VertexInComponentGraph[g,{v1,v2,…}]
gives the subgraph of the graph g generated by the vertices that have a directed path to at least one of v1,v2,….
VertexInComponentGraph[g,{v1,v2,…},k]
gives the subgraph of g generated by vertices with a directed path of at most length k to at least one of v1,v2,….
VertexInComponentGraph[g,{v1,v2,…},{k}]
gives the subgraph of g generated by vertices of length exactly k.
VertexInComponentGraph[{vw,…},…]
uses rules vw to specify the graph g.
Details and Options
- VertexInComponentGraph works with undirected graphs, directed graphs, multigraphs and mixed graphs.
Examples
open all close allBasic Examples (3)
Find the in-component graph of a vertex:
g = [image];VertexInComponentGraph[g, {3}]Highlight the in-component graph of a vertex:
HighlightGraph[g, %]Find the in-component graph of a set of vertices in a graph:
VertexInComponentGraph[[image], {3, 4}]Highlight the in-component graph of a vertex:
g = GridGraph[{5, 5}, VertexSize -> Medium, DirectedEdges -> True, EdgeStyle -> Arrowheads[Small]];Table[HighlightGraph[g, {Style[19, Blue], VertexInComponentGraph[g, {19}, i]}], {i, 3}]Scope (9)
VertexInComponentGraph works with undirected graphs:
VertexInComponentGraph[[image], {1}]VertexInComponentGraph[[image], {2}]VertexInComponentGraph[[image], {6}]VertexInComponentGraph[[image], {2}]VertexInComponentGraph[[image], {1}]Use rules to specify the graph:
VertexInComponentGraph[{1 -> 2, 1 -> 5, 2 -> 3, 3 -> 4, 4 -> 5, 6 -> 3, 4 -> 6}, {2}]Use patterns to select a subset of vertices:
VertexInComponentGraph[[image], _ ? EvenQ]Find the in-component graph connected to a vertex by a path of at most length 2 in a graph:
VertexInComponentGraph[[image], 6, 2]VertexInComponentGraph works with large graphs:
g = GridGraph[{10, 10, 10, 10}];VertexInComponentGraph[g, {1}] //VertexCount// TimingApplications (2)
Find the message generating the largest total number of messages in the network of email sent to the MathGroup list in November 2011:
g = ExampleData[{"NetworkGraph", "EmailListMathGroup"}];s = Table[Length[VertexInComponent[g, v]], {v, VertexList[g]}];v = Pick[VertexList[g], s, Max[s]]The most interesting subject of the month:
PropertyValue[{g, First[v]}, "Subject"]Show the network generated by this message:
VertexInComponentGraph[g, v]Build a graph by states that can reach to state 4 within a finite step in a finite-state Markov chain with the following transition probability matrix:
m = (| | | | | | |
| --- | --- | --- | --- | --- | --- |
| 1 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 0 | 0 | 1 | 0 |
| 0 | 0 | 0.2 | 0.5 | 0.3 | 0 |
| 0.7 | 0 | 0 | 0 | 0 | 0.3 |
| 0 | 0.6 | 0 | 0 | 0.4 | 0 |
| 0.8 | 0 | 0 | 0.2 | 0 | 0 |);Construct the state transition diagram of a transition matrix:
g = AdjacencyGraph[Unitize[m], VertexLabels -> Placed["Name", Center], VertexSize -> .35, EdgeStyle -> Arrowheads[.04], VertexStyle -> LightDarkSwitched[White, GrayLevel[0.2]]]Build the graph by states that can reach to state 4:
VertexInComponentGraph[g, 4]Properties & Relations (1)
Use VertexInComponent to find the in-component graph:
g = [image];VertexInComponent[g, {5}]Subgraph[g, %]VertexInComponentGraph[g, {5}]Related Guides
History
Text
Wolfram Research (2021), VertexInComponentGraph, Wolfram Language function, https://reference.wolfram.com/language/ref/VertexInComponentGraph.html.
CMS
Wolfram Language. 2021. "VertexInComponentGraph." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/VertexInComponentGraph.html.
APA
Wolfram Language. (2021). VertexInComponentGraph. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/VertexInComponentGraph.html
BibTeX
@misc{reference.wolfram_2026_vertexincomponentgraph, author="Wolfram Research", title="{VertexInComponentGraph}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/VertexInComponentGraph.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_vertexincomponentgraph, organization={Wolfram Research}, title={VertexInComponentGraph}, year={2021}, url={https://reference.wolfram.com/language/ref/VertexInComponentGraph.html}, note=[Accessed: 13-June-2026]}