Graph Theory - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


GraphTheory

A substantial effort was put into Graph Theory for Maple 2021, including new commands for graph computation and advances in visualization.

withGraphTheory:

 

New commands

New functionality for existing commands

Performance improvements

Additions to SpecialGraphs

New commands

These commands are new for Maple 2021:

EgoGraph

GraphDensity

IdentifyGraph

IsSubgraphIsomorphic

LeafPower

Newick

PrueferCode

SpanningForest

 

Tree encodings: Newick and PrueferCode

The new Newick and PrueferCode offer alternate ways to encode a tree as a string or list of integers.

T  RandomGraphs:-RandomTree25,seed=1024

TGraph 1: an undirected unweighted graph with 25 vertices and 24 edge(s)

(1.1.1)

DrawGraphT,style=tree

NewickT

(((7)13)14,(3)18,(((21)12,22)10,(((15,((5,9,23)2,16)19)4,8,(20)25)6,11)17)24)1;

(1.1.2)

PrueferCodeT

18,2,13,6,2,17,14,1,4,19,1,24,25,12,10,10,24,2,19,4,6,17,6

(1.1.3)

IdentifyGraph: find isomorphisms among named special graphs

IdentifyGraph tests a graph for isomorphism against many of the named special graphs known to GraphTheory.

In this example we begin by picking any edge a,b from the Hoffman-Singleton graph and deleting all vertices incident to a or b.

HS SpecialGraphs:-HoffmanSingletonGraph

HSGraph 2: an undirected unweighted graph with 50 vertices and 175 edge(s)

(1.2.1)

edge  EdgesHS100

edge20,25

(1.2.2)

G  DeleteVertexHS, convertNeighborhoodHS,edge1,set union convertNeighborhoodHS,edge2,set

GGraph 3: an undirected unweighted graph with 36 vertices and 90 edge(s)

(1.2.3)

With IdentifyGraph, we discover that this subgraph has a name: it is isomorphic to the Sylvester graph.

IdentifyGraphG

SpecialGraphs:−SylvesterGraph

(1.2.4)

IsSubgraphIsomorphic: test for isomorphism against subgraphs of a graph

IsSubgraphIsomorphic tests whether a given graph is isomorphic to a subgraph of another given graph. This problem is strictly harder than the graph isomorphism problem.

Returning to the above example, here we show again that the Sylvester graph is isomorphic to a subgraph of the Hoffman-Singleton graph. Note however that we did not need to explicit construct the subgraph beforehand.

SG SpecialGraphs:-SylvesterGraph

SGGraph 4: an undirected unweighted graph with 36 vertices and 90 edge(s)

(1.3.1)

IsSubgraphIsomorphicSG, HS

true

(1.3.2)

New functionality for existing commands

The BipartiteMatching command has been extended to support weighted graphs, on which it computes a minimum weight maximum matching using the Kuhn-Munkres algorithm, also known as the Hungarian algorithm.

We begin with a 7x7 matrix whose rows represent seven workers and whose columns represent seven tasks, in which entry i,j represents the cost for worker i to complete task j. Our goal is to find an assignment of tasks to workers which minimizes the total cost.

M  1277333371953639979067279973438957818445629664101136584067728023916153447077236544564778465:

dataplotM,heatmap,color=green..red

We now transform M into a 14x14 block matrix which will be the weight matrix for a bipartite graph:

WM   Matrix Matrix7;M|M%T;Matrix7

The 14 vertices of this graph will be the seven workers and seven tasks.

V  seqsprintfWorker %d, i,i=1..7,seqsprintfTask %d, i,i=1..7;

VWorker 1,Worker 2,Worker 3,Worker 4,Worker 5,Worker 6,Worker 7,Task 1,Task 2,Task 3,Task 4,Task 5,Task 6,Task 7

(2.1)

G  GraphTheory:-GraphV, WM

GGraph 5: an undirected weighted graph with 14 vertices and 49 edge(s)

(2.2)

Here we see an optimal solution for this problem, assigning Task 1 to Person 7, Task 2 to Person 2, etc.

GraphTheory:-BipartiteMatchingG

153,Task 1,Worker 7,Task 2,Worker 2,Task 3,Worker 1,Task 4,Worker 5,Task 5,Worker 6,Task 6,Worker 3,Task 7,Worker 4

(2.3)

 

Here is constructed the bipartite graph explicitly, but we can optionally also simply provide the original 7x7 matrix M directly to BipartiteMatching to produce a similar result:

GraphTheory:-BipartiteMatchingM

153,1,7,2,2,3,1,4,5,5,6,6,3,7,4

(2.4)

Performance improvements

The performance of the following GraphTheory commands has been substantially improved:

Command

Approximate Speedup Factor
(compared with Maple 2020)

AllPairsDistance (weighted)

3.1

Digraph

4.8

Graph

8.8

GraphPower

4.6

IsBipartite

200

RandomBipartiteGraph

18

RandomDigraph

18

RandomGraph

22

RandomTournament

35

ReverseGraph

18

TransitiveClosure (unweighted)

2.5

TransitiveClosure (weighted)

3.4

TransitiveReduction (unweighted)

7.6

TransitiveReduction (weighted)

3.4

UnderlyingGraph

4.0

Additions to SpecialGraphs

Maple 2021 provides support for 16 additional Special Graphs, bringing the total to 113.  

withSpecialGraphs:

Banana Tree

Bidiakis Cube

Butterfly Graph

Crown Graph

DrawGraphBananaTree5,4,size=250,250

DrawGraphBidiakisCube,size=250,250

DrawGraphButterflyGraph,size=250,250

DrawGraphCrownGraph6,size=250,250

Goldner-Harary Graph

Gosset Graph

King's Graph

Kittell Graph

DrawGraphGoldnerHararyGraph,size=250,250

DrawGraphGossetGraph,style=spring

DrawGraphKingsGraph8,8,size=300,300

DrawGraphKittellGraph,style=planar,size=250,250

Knight's Graph

Krackhardt Kite Graph

Ladder Graph

Markström Graph

DrawGraphKnightsGraph8,8,size=300,300

DrawGraphKrackhardtKiteGraph,size=250,250,style=spring

DrawGraphLadderGraph5,size=250,250

DrawGraphMarkstroemGraph,style=planar,size=250,250

Queen's Graph

Sousselier Graph

Walther Graph

Watkins Snark

DrawGraphQueensGraph8,8,size=300,300

DrawGraphSousselierGraph, size=250,250

DrawGraphWaltherGraph,size=300,300

DrawGraphWatkinsSnark, style=spring,size=300,300