3
$\begingroup$

How do I specify the style of individual edges in a directed graph (in Mathematica version 9)?

Consider maybe this

Graph[{"ftr1" -> "ftr2", "ftr2" -> "ftr3", "ftr3" -> "ftr4"}]

How can I change the color and make dashed the individual edges in any manner that I'd like? It seems like

Graph[{"ftr1" -> "ftr2", "ftr2" -> "ftr3", "ftr3" -> "ftr4"}, EdgeStyle -> {"ftr1" -> "ftr2" -> Black, "ftr2" -> "ftr3" -> Blue, "ftr3" -> "ftr4" -> Green}]

Fails for directed graphs, but works for undirected graphs

Graph[{"ftr1" \[UndirectedEdge] "ftr2", "ftr2" \[UndirectedEdge] "ftr3", "ftr3" \[UndirectedEdge] "ftr4"}, EdgeStyle -> {"ftr1" \[UndirectedEdge] "ftr2" -> Black, "ftr2" \[UndirectedEdge] "ftr3" -> Blue, "ftr3" \[UndirectedEdge] "ftr4" -> Green}]
$\endgroup$

closed as off-topic by Öskå, Dr. belisarius, Michael E2, Mr.Wizard Jan 11 '15 at 9:52

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Öskå, Dr. belisarius, Michael E2, Mr.Wizard
If this question can be reworded to fit the rules in the help center, please edit the question.

4
$\begingroup$

As halmir commented the documentation of EdgeStyle notes the following possible issue:

enter image description here


Thus you should use \[DirectedEdge]:

Graph[
  {"ftr1" \[DirectedEdge] "ftr2", 
   "ftr2" \[DirectedEdge] "ftr3", 
   "ftr3" \[DirectedEdge] "ftr4"}, 
 EdgeStyle -> 
  {"ftr1" \[DirectedEdge] "ftr2" -> Black, 
   "ftr2" \[DirectedEdge] "ftr3" -> Blue, 
   "ftr3" \[DirectedEdge] "ftr4" -> Green}]

Mathematica graphics

$\endgroup$
  • 1
    $\begingroup$ Not a bug. It's documented (under possible issue in EdgeStyle documentation). $\endgroup$ – halmir Jan 9 '15 at 14:07
  • $\begingroup$ @halmir Thank you, edited the answer :) $\endgroup$ – Öskå Jan 9 '15 at 14:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.