Message Boards Message Boards

Set EdgeStyles on a Directed Graph?

Posted 9 years ago

Hello, I wonder if anyone can help me understand how to use EdgeStyles on a directed graph.

On an un-directed graph I can do the following:

Graph[{1<->2,3 <-> 2,1<->3}, EdgeStyle -> {1<->2-> Directive[Thickness[0.01],Blue], 3 <-> 2 -> Directive[Thickness[0.005],Red], 
1<-> 3 -> Directive[Thickness[0.02],Green]}]

But on a directed graph the following does not work:

Graph[{1->2,3 -> 2,1->3}, EdgeStyle -> {1->2-> Directive[Thickness[0.01],Blue], 3 -> 2 -> Directive[Thickness[0.005],Red], 
1-> 3 ->  Directive[Thickness[0.02],Green]}]

Can someone help me understand what I am missing here?

Thank you, Grey

POSTED BY: Grey Nearing
2 Replies
Posted 9 years ago

To add to this question, I would like to ultimately have a directed graph with variable edge colors and edge widths to represent the varying strengths of (directed) interactions between nodes in a network. I would also like to be able to control the coordinates where each vertex is plotted.

So far I have figured out that GraphPlot, allows specification of coordinates for vertices: GraphPlot[{1->2,2->3,3->1},VertexCoordinateRules->{1->{0,0},2->{1,1},3->{0,2}}]

And Graph apparently allows full controls of the edge widths: Graph[{1<->2,3 <-> 2,1<->3}, EdgeStyle -> {1<->2-> Directive[Thickness[0.01],Blue], 3 <-> 2 -> Directive[Thickness[0.005],Red], 1<-> 3 -> Directive[Thickness[0.02],Green]}]

But, the EdgeStyle Directives cannot be set for directed edges (as in the original question). Further, VertexCoordinateRules fors not work for Graph and EdgeStyle does not work for GraphPlot.

Is there a way to get everything that I want (control over vertex coordinates, and also control over individual edge widths)?

POSTED BY: Grey Nearing

Just use parentheses:

Graph[{1 -> 2, 3 -> 2, 1 -> 3}, 
 EdgeStyle -> {(1 -> 2) -> 
    Directive[Thickness[0.01`], RGBColor[0, 0, 1]], (3 -> 2) -> 
    Directive[Thickness[0.005`], RGBColor[1, 0, 0]], (1 -> 3) -> 
    Directive[Thickness[0.02`], RGBColor[0, 1, 0]]}]
POSTED BY: Saso Tomazic
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract