WLJS LogoWLJS Notebook

AdjacencyMatrix

AdjacencyMatrix[g] gives the adjacency matrix of graph g, where entry (i,j)(i,j) is 1 if vertices ii and jj are connected.

Examples

Get adjacency matrix:

g = Graph[{1 <-> 2, 2 <-> 3, 3 <-> 1}]

AdjacencyMatrix[g] // MatrixForm
(*
  0 1 1
  1 0 1
  1 1 0
*)

AdjacencyMatrix[CompleteGraph[4]] // MatrixForm

Please visit the official Wolfram Language Reference for more details.

On this page