This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Number of nodes in graph


N = numnodes(G)



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


collapse all

Use the bucky adjacency 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 a graph or digraph object. Use graph to create an undirected graph or digraph to 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.

Introduced in R2015b