numnodes
Number of nodes in a graph.
Category: Mathematics > Graph and Network Algorithms
Syntax
n = numnodes(G)
Returns the number of nodes.
Description
Nodes with no edges are counted. The number of nodes is the largest index appearing in the edge lists given at construction, unless addnode raised it.
Input arguments
G- A
graphordigraph.
Output arguments
n- Scalar, the number of rows of
G.Nodes.
Example
Isolated nodes count
G = graph([1 2], [2 7]);
numnodes(G)
numedges(G)
Output
ans = 7
ans = 2