numedges

Number of edges in a graph.

Category: Mathematics > Graph and Network Algorithms

Syntax

n = numedges(G)

Returns the number of edges.

Description

It equals height(G.Edges). Parallel edges are counted separately. For an undirected graph the sum of all degrees is 2*numedges(G).

Input arguments

G
A graph or digraph.

Output arguments

n
Scalar, the number of rows of G.Edges.

Example

Counting

G = graph([1 1 2], [2 3 3]);
numedges(G)
numnodes(G)
Output
ans = 3
ans = 3

See also

numnodes degree edgecount graph