Self-Loops
The core routines of the GraphTheory package have been extended to support graphs with self-loops. Graphs with self-loops may be directed or undirected, and weighted or unweighted.
The number of self-loops in a graph is displayed in the graph description along with the vertex and edge count:
> |
 |
Several new commands have been added to work with self-loops:
- HasSelfLoops returns true if a graph has an edge or arc to itself.
- NumberOfSelfLoops returns the number of self-loops in a graph.
- SelfLoops returns the set of self-loops in a graph.
The HasSelfLoop and NumberOfSelfLoops commands permit querying graphs for the existence and number of self-loops, respectively, while SelfLoops returns the set of vertices with self-loops.
> |
 |
> |
 |
> |
 |
Directed Graphs with Self-Loops
The support for self-loops extends to both directed and undirected graphs. Here is a directed graph with a self-loop at vertex 1:
> |
![G1 := Graph({[1, 1], [1, 2], [1, 3], [1, 4], [2, 3], [3, 4]});](graph-theory/GraphTheory_83.gif) |
> |
 |
> |
 |
The Edges command now returns self-loops in its list of edges. If only edges between distinct vertices are desired, the option selfloops=false can be specified:
> |
 |
> |
 |
The in-degree and out-degree of a vertex are each increased by one when it receives a self-loop:
> |
 |
> |
 |
Undirected Graphs with Self-Loops
We can produce a copy of G1 which discards the directionality of its edges while preserving self-loops by calling UnderlyingGraph with the selfloops option:
> |
 |
> |
 |
By convention, the degree of a vertex is increased by 2 when it receives a self-loop:
> |
 |
In a simple graph the smallest possible girth (length of the shortest cycle) is 3. In a graph with a self-loop, the length of the shortest cycle is 1:
> |
 |
By definition, any graph with a self-loop cannot be colored with any number of colors. The chromatic polynomial therefore is identically zero:
> |
 |
Removing self-loops
We can generate a copy of a graph with the self-loops removed simply by calling UnderlyingGraph without specifying the selfloops option:
> |
 |
> |
 |
> |
 |
> |
 |
> |
 |
 |
Geometric Graphs
A new Maple 2020 function in RandomGraphs subpackage generates a random geometric graph.
> |
 |
> |
 |
Maple 2020 contains a new subpackage, GeometricGraphs, for generating graphs from geometric data, such as a set of 2-D or 3-D points. This subpackage includes the following new commands:
|
- EuclideanMinimumSpanningTree
|
|
|
- GeometricMinimumSpanningTree
|
|
- RelativeNeighborhoodGraph
|
|
|
|
|
|
> |
 |
> |
 |
The Euclidean minimum spanning tree, the Delaunay graph, the Gabriel graph, the relative neighborhood graph, and the Urquhart graph are all derived from a Delaunay triangulation of the point data.
These graphs have a hierarchical relationship:
- The Euclidean minimum spanning tree is a subgraph of the relative neighborhood graph,
- The relative neighborhood graph is a subgraph of the Urquhart graph,
- The Urquhart graph is a subgraph of the Gabriel graph.
- The Gabriel graph is a subgraph of the Delaunay graph.
Euclidean Minimum Spanning Tree
|
Relative Neighborhood Graph
|
Urquhart Graph
|
Gabriel Graph
|
Delaunay Graph
|


|


|

|

|

|
Note that we can also build spanning trees for this point data using norms other than the Euclidean norm, for example the 1-norm; the result is similar but not identical to the Euclidean spanning tree.
NearestNeighborGraph and FarthestNeighborGraph return a nearest and farthest neighbor graph for a point set. You can also build k-nearest neighbor and k-farthest neighbor graphs for specified k.
Nearest Neighbor Graph
|
Farthest Neighbor Graph
|
2-Nearest Neighbor
|
2-Farthest Neighbor
|

|


|

|


|
The UnitDiskGraph command returns a graph in which two points are connected if their distance falls below a specified threshold.
> |
 |
For a set of points, SphereOfInfluenceGraph draws a circle around each point with radius equal to the distance to its nearest neighbor. The sphere of influence graph is the graph whose vertices correspond to these points in which an edge between two points exists if the corresponding circles intersect at more than one point.
> |
 |
Most of these graphs commands are not limited to two dimensions, and can be used to analyze and visualize relationships with higher-dimensional data as well.

Split Graphs
IsSplitGraph returns true if a graph is can be partitioned into a clique and an independent set.
> |
 |
> |
 |
> |
![HighlightSubgraph(G3, InducedSubgraph(G3, split[1]));](graph-theory/GraphTheory_169.gif) |
> |
 |
ContractSubgraph
The ContractSubgraph command returns a new graph with all the vertices in S merged into a single vertex. The neighborhood of the new vertex will be the union of the neighborhoods of all of merged vertices.
> |
 ![H := ContractSubgraph(C, [1, 2, 6]);](graph-theory/GraphTheory_173.gif) |
> |
 |
SpecialGraphs
Maple 2020 provides support for 18 additional Special Graphs, bringing the total to 97.
> |
 |
Barnette-Bosàk-Lederberg Graph
|
Berlekamp-van Lint-Seidel Graph
|
Biggs-Smith Graph
|
Brouwer-Haemers Graph
|
|
> |

 |
> |
 |
|
|
> |
 |
> |
 |
> |
 |
|
De Bruijn Graph
|
Gewirtz Graph
|
Golomb Graph
|
Harr Graph
|
> |
![DrawGraph(DeBruijnGraph(3, 2), size = [250, 250]);](graph-theory/GraphTheory_204.gif)
![DrawGraph(DeBruijnGraph(3, 2), size = [250, 250]);](graph-theory/GraphTheory_205.gif) |
|
> |
 |
> |
 |
> |
 |
|
|
|
Harborth Graph
|
Higman-Sims Graph
|
M22 Graph
|
McLaughlin Graph
|
|
> |
 |
> |
 |
> |
 |
|
> |
 |
> |

 |
> |
 |
|
> |
 |
> |
 |
|
Meredith Graph
|
Perkel Graph
|
Rooks Graph
|
Schläfli Graph
|
|
> |
 |
> |
 |
> |
 |
|
> |

 |
|
> |
 |
> |
 |
> |
 |
|
Wells Graph
|
Wiener-Araya Graph
|
|
|
> |
![DrawGraph(WellsGraph(), layout = spring, size = [250, 250]);](graph-theory/GraphTheory_279.gif)
![DrawGraph(WellsGraph(), layout = spring, size = [250, 250]);](graph-theory/GraphTheory_280.gif) |
|
> |

 |
|
|
|