labeledge
Adds labels to the edges of a graph plot.
Category: Mathematics > Graph and Network Algorithms
Syntax
labeledge(p, s, t, labels)
Labels the edge between s(k) and t(k) with labels(k).
labeledge(p, 'auto')
Labels the edges with their index, or weight if present.
Description
The labels appear next to the edge midpoints. They are a property of the plot, not of the graph, so they vanish when the plot is redrawn. Typical labels are weights or flow values.
Input arguments
p- GraphPlot object returned by
plot(G). s, t- End nodes of the edges to label.
labels- Cell array of text, or numeric vector, one entry per edge.
Example
Weights on the plot
G = graph([1 2 3], [2 3 4], [5 8 2]);
p = plot(G);
labeledge(p, [1 2 3], [2 3 4], G.Edges.Weight')
In the app, the plot shows 5, 8 and 2 next to the edges.