File Exchange

image thumbnail

Plot a Directed Graph (v2.0)

version 1.0 (2.43 KB) by

plots a directed graph represented by an adjacency matrix and xy points

14 Downloads

Updated

View License

GPLOTDC Plot a Directed Graph
GPLOTDC(A,XY) Plots the Directed Graph represented by adjacency matrix A and points xy using the default style described below
GPLOTDC(A,XY,PARAM1,VAL1,PARAM2,VAL2,...) Plots the Directed Graph using valid parameter name/value pairs

Inputs:
A - NxN adjacency matrix, where A(I,J) is nonzero (=1) if and only if there is an edge between points I and J
xy - Nx2 matrix of x/y coordinates
... - Parameter name/value pairs that are consistent with valid PLOT parameters can also be specified
 
Default Plot Style Details:
1. Undirected (2-way) edges are plotted as straight solid lines (blue)
2. Directed (1-way) edges are plotted as curved dotted lines with the curvature bending counterclockwise moving away from a point (red)
3. Any vertex that is connected to itself is plotted with a circle around it (black)

Note: The directed edges are curved, thus providing an easy visualization of the edge direction. The curvature bends counterclockwise (or to the right of a straight line) for edges moving away from a point. For example, in the screenshot, there is an edge connecting point 6 to point 7, and one connecting point 8 to point 5, but not the other way around.

Comments and Ratings (2)

excuse me, could you tell me how to execute this code and where to insert the inputs? thank you!

Vladimir

The idea with indicating edge directions by right-hand-curved lines is outstanding!

MATLAB Release
MATLAB 7.6 (R2008a)
Acknowledgements

Inspired by: Plot a Directed Graph

Inspired: Exact controllability of complex networks

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video