How can I format individual edges in a directed graph?

Hi all -
I am plotting a directed graph, however the formatting is really important to get right so I can achieve the objectives in my assignment. However, I would need to format each edge individually. An edge will have certain formats if a certain condition is met.
How do I get different edge layouts in the same graph and plot it? I am not finding this anywhere on the internet. Is this possible?
All the best.

6 Comments

What kind of "formatting" is required? Color? Arrow style? Line width? Dash/dot pattern? Color range? Variable thickness? Line must take certain paths such as restricted to horizontal/vertical and 90 degree turns?
basically color, arrow style (not much importante actually), line width.
highlight() allows you to control edgecolor and linewidth, but not arrow style.
Thank you for the answer, Walter! Much appreciated. Actually I wouldn't need the arrow style to be different in different edges. Using the same arrow style would still solve my problem. But just to make sure: using the highlight() function would help me control edge color and line width correct? But would it be possible to get different edges with different colors and widths with this? How about edge line style? Like dotted lines, etc?
See the documentation pages to which I linked in my Answer; they show how to use highlight and property manipulation to do what you're asking.
Thank you very much Steven! Much appreciated. Just one last question: is there a way to loop through the edges? I wanted to do something like loop through the edges, and if the edge has a certain length, format that individual edge a certain way. How can this be done?
Best.

Sign in to comment.

 Accepted Answer

You can control some properties of the edge lines in the plot of a graph or digraph on a per-edge basis using the highlight function or by directly manipulating the properties of the GraphPlot object as the "Edge Line Width by Weight" example on this documentation page shows.

More Answers (0)

Categories

Find more on Graph and Network Algorithms in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!