gplot
Draws a graph from its adjacency matrix and node coordinates.
Category: Mathematics > Sparse Matrices
Syntax
gplot(A, xy)
Plots a line between nodes i and j wherever A(i,j) is nonzero.
gplot(A, xy, LineSpec)
Uses a line specification such as '-o' for color, style and markers.
Description
gplot is a lightweight way to look at a graph or at the connectivity of a sparse matrix. The positions come from xy, so you choose the layout: coordinates from a mesh, the output of treelayout, points on a circle, and so on. Edges are drawn once for each nonzero entry in the matrix.
Input arguments
A- Square adjacency matrix, sparse or full.
xyn-by-2 (orn-by-3) matrix: rowiholds the coordinates of nodei.LineSpec- Optional line style, color and marker string.
Example
A triangle with a tail
A = sparse([0 1 1 0; 1 0 1 0; 1 1 0 1; 0 0 1 0]);
xy = [0 0; 1 0; 0.5 1; 2 1];
gplot(A, xy, '-o')