Close
Close window
Contract - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.
Maplesoft logo
Maplesoft logo

Online Help

All Products Maple MapleSim


[フレーム] [フレーム]

GraphTheory

Contract

contract edge of a graph

Calling Sequence

Contract(G, e, opts)

Parameters

G

-

graph

e

-

edge of the graph

opts

-

(optional) one or more options as described below

Options

multigraph = truefalse

Specifies that the output should be a multigraph if there is an edge created by contracting e between two vertices which were already connected. The default is false.

weighted = truefalse

Specifies that the output should be weighted. If G is unweighted, the edge weights of the result matrix correspond to the edge multiplicity of a given edge. The default is false, unless multigraph=true.

Description

The Contract command contracts the specified edge of a graph. By default, all the loops and multiple edges are removed.

By setting multigraph=true, the loops and multiple edges are preserved and the output is a weighted graph.

To contract multiple edges in a graph, use ContractSubgraph or use the foldl command.

Examples

>

withGraphTheory:

>

withSpecialGraphs:

>

GCompleteGraph4

GGraph 1: an undirected graph with 4 vertices and 6 edges

(1)
>

ContractG,1,3

Graph 2: an undirected graph with 3 vertices and 3 edges

(2)
>

ContractG,1,3,multigraph=true

Graph 3: an undirected multigraph with 3 vertices, 5 edges, and 1 self-loop

(3)
>

PPetersenGraph

PGraph 4: an undirected graph with 10 vertices and 15 edges

(4)
>

DrawGraphP

Contract the five edges connecting the inner star to the outer pentagon to show K5.

>

GfoldlContract,P,1,6,2,9,3,7,4,10,5,8

GGraph 5: an undirected graph with 5 vertices and 10 edges

(5)
>

NumberOfVerticesG

5

(6)
>

IsCliqueG

true

(7)


Download Help Document

AltStyle によって変換されたページ (->オリジナル) /