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

Online Help

All Products    Maple    MapleSim


GraphTheory

  

AdjacencyMatrix

  

construct adjacency matrix

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

AdjacencyMatrix(G, opts)

AdjacencyMatrix(G, L, opts)

Parameters

G

-

graph

L

-

values for adjacent, nonadjacent, and diagonal entries

opts

-

(optional) one or more options as specified below

Options

• 

datatype=type

  

Specifies a datatype for the generated Matrix as described in rtable. The default is datatype=anything.

• 

order=one of C_order or Fortran_order

  

Specifies the order of the generated Matrix. The default is order=C_order.

• 

shape=name or list of names

  

Specifies the storage allocation for Matrix entries. Must be a name or list of names specifying one or more built-in or user-defined indexing functions. The default is shape=symmetric if G is undirected and shape=[] if G is directed.

• 

storage=name

  

Specifies the storage mode. The default is storage=sparse if the number of edges is much smaller than the square of the number of vertices; otherwise, it is storage=triangular[upper] if G is undirected and storage=rectangular if G is directed.

Description

• 

The AdjacencyMatrix command returns the adjacency matrix of a graph G whose rows and columns are indexed by the vertices. The entry i,j of this matrix is 1 if there is an edge from vertex i to vertex j and 0 otherwise.

• 

The optional parameter L is a list of three elements specifying alternate special-purpose values for the entries of the adjacency matrix. If specified, the generated matrix has the following properties:

– 

A[i,j] = L[1] when there is an edge from i to j in G

– 

A[i,j] = L[2] when there is no edge from i to j in G

– 

A[i,i] = L[3] along the diagonal

  

The default behavior corresponds to specifying the list [1,0,0].

• 

The default output is an n by n Matrix with the following properties:

– 

If G is directed or undirected: datatype=anything and order=C_order

– 

If G is undirected: shape=symmetric, storage=triangular[upper],

– 

If G is directed: storage=rectangular, shape=[]

– 

If G is sparse, i.e., |E| << |V|^2 then storage=sparse is used.

Examples

withGraphTheory&colon;

GGraph1&comma;2&comma;3&comma;4&comma;Trail1&comma;2&comma;3&comma;4&comma;1

GGraph 1: an undirected graph with 4 vertices and 4 edge(s)

(1)

AdjacencyMatrixG

0101101001011010

(2)

NeighborsG

2&comma;4&comma;1&comma;3&comma;2&comma;4&comma;1&comma;3

(3)

HDigraph1&comma;2&comma;3&comma;4&comma;Trail1&comma;2&comma;3&comma;4&comma;1

HGraph 2: a directed graph with 4 vertices and 4 arc(s)

(4)

AdjacencyMatrixH

0100001000011000

(5)

DeparturesH

2&comma;3&comma;4&comma;1

(6)

Compatibility

• 

The GraphTheory[AdjacencyMatrix] command was updated in Maple 2021.

• 

The L parameter was introduced in Maple 2021.

• 

The datatype, order, shape and storage options were introduced in Maple 2021.

• 

For more information on Maple 2021 changes, see Updates in Maple 2021.

See Also

Degree

Departures

Neighbors

Trail