Main Content

successors

Node successors

Description

example

sucIDs= successors(G,nodeID)returns the successor nodes of the node in directed graphGspecified bynodeID. The successor nodes form directed edges withnodeIDas the source node, andsucIDsas the target nodes.

Examples

collapse all

Create and plot a directed graph and determine the successor nodes of node'a'.

s = [1 1 1 2 2 3 3 7 8]; t = [2 3 4 5 6 7 8 5 5]; names = {'a''b''c''d''e''f''g''h'}; G = digraph(s,t,[],names); plot(G)

Figure contains an axes object. The axes object contains an object of type graphplot.

sucIDs =继任者(G,'a')
sucIDs =3x1 cell{'b'} {'c'} {'d'}

Input Arguments

collapse all

Input graph, specified as adigraphobject. Usedigraphto create a directed graph object.

Example:G = digraph([1 2],[2 3])

Node identifier, specified as one of the values in this table.

Value Example
Scalar node index 1
Character vector node name 'A'
String scalar node name "A"

Example:sucIDs =继任者(G,3)finds the successor nodes of node 3.

Output Arguments

collapse all

赛克赛斯sor node IDs, returned as a node indices or node names.

  • IfnodeIDis a numeric node index, thensucIDscontains numeric node indices.

  • IfnodeIDis a node name, thensucIDscontains node names.

Tips

  • For multigraphs with multiple edges between the same two nodes, the output ofoutedgescan be longer than that ofsuccessors, since there can be multiple outgoing edges to some of the successors.

Version History

Introduced in R2015b