Main Content

numnodes

Number of nodes in graph

Description

example

N= numnodes(G)returns the number of nodes in graphG.

Examples

collapse all

Use thebuckyadjacency matrix to create a directed graph, and then determine how many nodes the graph contains.

G = digraph(bucky)
G = digraph with properties: Edges: [180x2 table] Nodes: [60x0 table]
N = numnodes(G)
N = 60

Input Arguments

collapse all

Input graph, specified as either agraphordigraphobject. Usegraphto create an undirected graph ordigraphto create a directed graph.

Example:G = graph(1,2)

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

Output Arguments

collapse all

Number of nodes, returned as a scalar.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2015b