WLJS LogoWLJS Notebook

WeightedAdjacencyMatrix

WeightedAdjacencyMatrix[g] gives the adjacency matrix of edge weights of the graph g.

WeightedAdjacencyMatrix[{v -> w, ...}] uses rules to specify the graph g.

Examples

Get the weighted adjacency matrix of a graph:

g = Graph[{1 -> 2, 2 -> 3}, EdgeWeight -> {2, 3}];
WeightedAdjacencyMatrix[g] // MatrixForm

Create from explicit edges:

WeightedAdjacencyMatrix[{1 <-> 2, 2 <-> 3, 3 <-> 1}]

Please visit the official Wolfram Language Reference for more details.

On this page