GraphTheory - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Mathematics : Discrete Mathematics : Graph Theory : GraphTheory Package : GraphTheory/Edges

GraphTheory

 Edges
 Vertices

 Calling Sequence Edges(G,opts) Vertices(G)

Parameters

 G - a graph opts - zero or or more options as specified below

Options

 • selfloops=truefalse
 Specifies whether self-loops should be included in the set of edges returned. The default value is true.
 • weights=truefalse
 Specifies whether weights should be included in the output. If true, each element of the resulting set is a list whose first element is the edge, and whose second element is the edge weight. The default value is false.

Description

 • The Edges(G,opts) function returns a set of the edges of G.
 • The Vertices(G) function returns a list of the vertex labels of G.
 • To count vertices and edges, use the NumberOfEdges or NumberOfVertices commands.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $G≔\mathrm{Graph}\left(\left[1,2,3,4\right],\left\{\left\{1,2\right\},\left\{1,3\right\},\left\{1,4\right\}\right\}\right)$
 ${G}{≔}{\mathrm{Graph 1: an undirected unweighted graph with 4 vertices and 3 edge\left(s\right)}}$ (1)
 > $\mathrm{Vertices}\left(G\right)$
 $\left[{1}{,}{2}{,}{3}{,}{4}\right]$ (2)
 > $\mathrm{Edges}\left(G\right)$
 $\left\{\left\{{1}{,}{2}\right\}{,}\left\{{1}{,}{3}\right\}{,}\left\{{1}{,}{4}\right\}\right\}$ (3)
 > $G≔\mathrm{Graph}\left(\left[a,b,c\right],\left\{\left[a,b\right],\left[b,c\right],\left[c,a\right]\right\}\right)$
 ${G}{≔}{\mathrm{Graph 2: a directed unweighted graph with 3 vertices and 3 arc\left(s\right)}}$ (4)
 > $\mathrm{Vertices}\left(G\right)$
 $\left[{a}{,}{b}{,}{c}\right]$ (5)
 > $\mathrm{Edges}\left(G\right)$
 $\left\{\left[{a}{,}{b}\right]{,}\left[{b}{,}{c}\right]{,}\left[{c}{,}{a}\right]\right\}$ (6)
 > $A≔\mathrm{Matrix}\left(\left[\left[0,1,1\right],\left[1,0,1\right],\left[1,1,0\right]\right]\right):$
 > $G≔\mathrm{Graph}\left(A\right)$
 ${G}{≔}{\mathrm{Graph 3: an undirected unweighted graph with 3 vertices and 3 edge\left(s\right)}}$ (7)
 > $\mathrm{Edges}\left(G\right)$
 $\left\{\left\{{1}{,}{2}\right\}{,}\left\{{1}{,}{3}\right\}{,}\left\{{2}{,}{3}\right\}\right\}$ (8)
 > $A≔\mathrm{Matrix}\left(\left[\left[0.,0.5,0.\right],\left[0.,0.,1.0\right],\left[1.5,0.,0.\right]\right]\right):$
 > $G≔\mathrm{Graph}\left(A\right)$
 ${G}{≔}{\mathrm{Graph 4: a directed weighted graph with 3 vertices and 3 arc\left(s\right)}}$ (9)
 > $\mathrm{Edges}\left(G\right)$
 $\left\{\left[{1}{,}{2}\right]{,}\left[{2}{,}{3}\right]{,}\left[{3}{,}{1}\right]\right\}$ (10)
 > $\mathrm{Edges}\left(G,'\mathrm{weights}'\right)$
 $\left\{\left[\left[{1}{,}{2}\right]{,}{0.5}\right]{,}\left[\left[{2}{,}{3}\right]{,}{1.0}\right]{,}\left[\left[{3}{,}{1}\right]{,}{1.5}\right]\right\}$ (11)

Compatibility

 • The GraphTheory[Edges] and GraphTheory[Vertices] commands were updated in Maple 2020.
 • The selfloops option was introduced in Maple 2020.
 • For more information on Maple 2020 changes, see Updates in Maple 2020.

 See Also