GraphTheory
AdjacencyMatrix
Calling Sequence
Parameters
Description
Examples
AdjacencyMatrix(G)
G
-
graph
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 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 will be used.
with⁡GraphTheory:
G≔Graph⁡1,2,3,4,Trail⁡1,2,3,4,1
G≔Graph 1: an undirected unweighted graph with 4 vertices and 4 edge(s)
AdjacencyMatrix⁡G
0101101001011010
Neighbors⁡G
2,4,1,3,2,4,1,3
H≔Digraph⁡1,2,3,4,Trail⁡1,2,3,4,1
H≔Graph 2: a directed unweighted graph with 4 vertices and 4 arc(s)
AdjacencyMatrix⁡H
0100001000011000
Departures⁡H
2,3,4,1
See Also
Degree
Departures
Neighbors
Trail
Download Help Document
What kind of issue would you like to report? (Optional)