ismultigraph

Tests whether a graph has parallel edges.

Category: Mathematics > Graph and Network Algorithms

Syntax

tf = ismultigraph(G)

Returns true if some pair of nodes is joined by more than one edge.

Description

A graph that repeats an edge in its edge list is a multigraph. Self-loops alone do not make a multigraph. Many algorithms expect simple graphs, so this test is a quick check before calling them. edgecount tells how many edges join a given pair.

Input arguments

G
A graph or digraph.

Output arguments

tf
Logical scalar.

Example

Repeated edge

ismultigraph(graph([1 1 2], [2 2 3]))
ismultigraph(graph([1 1 2], [2 3 3]))
Output
ans = logical
   1
ans = logical
   0

See also

edgecount simplify numedges graph