GraphTheory - Maple Programming Help

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

GraphTheory

 GraphEqual

 Calling Sequence GraphEqual(G, H)

Parameters

 G, H - graphs

Description

 • GraphEqual(G,H) returns true if the two input graphs are equal. Here the graphs are equal if they are (i) both directed or both undirected, (ii) both weighted or both unweighted, (iii) have the same vertex labels and in the same order, (iv) have the same edges. Further, if the graphs are both weighted graphs, their edge weights must be equal and integer edge weights are considered different from floating-point edge weights.
 • Thus G = Graph([1,2,3],{{1,2},{2,3}}) is considered not equal to H = Graph([1,3,2],{{1,2},{2,3}}) even though their edge sets are the same. If you want to test if the graphs are equal up to a permutation of the vertices then you may compare if their edge sets are equal.

Examples

 > $\mathrm{with}\left(\mathrm{GraphTheory}\right):$
 > $G≔\mathrm{Graph}\left(\left[1,2,3\right],\left\{\left\{1,2\right\},\left\{2,3\right\}\right\}\right)$
 ${G}{≔}{\mathrm{Graph 1: an undirected unweighted graph with 3 vertices and 2 edge\left(s\right)}}$ (1)
 > $H≔\mathrm{Graph}\left(\left[1,2,3\right],\left\{\left\{1,2\right\},\left\{1,3\right\}\right\}\right)$
 ${H}{≔}{\mathrm{Graph 2: an undirected unweighted graph with 3 vertices and 2 edge\left(s\right)}}$ (2)
 > $\mathrm{Vertices}\left(G\right),\mathrm{Edges}\left(G\right)$
 $\left[{1}{,}{2}{,}{3}\right]{,}\left\{\left\{{1}{,}{2}\right\}{,}\left\{{2}{,}{3}\right\}\right\}$ (3)
 > $\mathrm{Vertices}\left(H\right),\mathrm{Edges}\left(H\right)$
 $\left[{1}{,}{2}{,}{3}\right]{,}\left\{\left\{{1}{,}{2}\right\}{,}\left\{{1}{,}{3}\right\}\right\}$ (4)
 > $\mathrm{GraphEqual}\left(G,H\right)$
 ${\mathrm{false}}$ (5)
 > $H≔\mathrm{Graph}\left(\mathrm{Trail}\left(1,2,3\right)\right)$
 ${H}{≔}{\mathrm{Graph 3: an undirected unweighted graph with 3 vertices and 2 edge\left(s\right)}}$ (6)
 > $\mathrm{Vertices}\left(H\right),\mathrm{Edges}\left(H\right)$
 $\left[{1}{,}{2}{,}{3}\right]{,}\left\{\left\{{1}{,}{2}\right\}{,}\left\{{2}{,}{3}\right\}\right\}$ (7)
 > $\mathrm{GraphEqual}\left(G,H\right)$
 ${\mathrm{true}}$ (8)
 > $G≔\mathrm{Graph}\left(\left[a,b,c\right],\left\{\left\{a,b\right\},\left\{b,c\right\}\right\}\right)$
 ${G}{≔}{\mathrm{Graph 4: an undirected unweighted graph with 3 vertices and 2 edge\left(s\right)}}$ (9)
 > $H≔\mathrm{PermuteVertices}\left(G,\left[a,c,b\right]\right)$
 ${H}{≔}{\mathrm{Graph 5: an undirected unweighted graph with 3 vertices and 2 edge\left(s\right)}}$ (10)
 > $\mathrm{Vertices}\left(G\right),\mathrm{Edges}\left(G\right)$
 $\left[{a}{,}{b}{,}{c}\right]{,}\left\{\left\{{a}{,}{b}\right\}{,}\left\{{b}{,}{c}\right\}\right\}$ (11)
 > $\mathrm{Vertices}\left(H\right),\mathrm{Edges}\left(H\right)$
 $\left[{a}{,}{c}{,}{b}\right]{,}\left\{\left\{{a}{,}{b}\right\}{,}\left\{{b}{,}{c}\right\}\right\}$ (12)
 > $\mathrm{GraphEqual}\left(G,H\right)$
 ${\mathrm{false}}$ (13)