4

Bug introduced in version 9.0 or earlier and fixed in 10.3


It's very weird, but the first graph is shown as undirected (dots connected by lines, not arrows. The second is shown as directed, with arrows. I'm using the cloud version of Mathematica.

Grafo1=Graph[{1,2,3},{1->2, 3->3, 3->1}]
Grafo2=Graph[{1,2,3},{1->2, 3->3, 3->1, 2->3}]

Anyone has ideas?

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
asdf
  • 184
  • 6
  • even with Grafo1=Graph[{1,2,3},{1->2, 3->3, 3->1}, DirectedEdges->True] i got the same graph. – asdf Jun 30 '15 at 14:05

1 Answers1

9

Both are directed. The arrows are there but they're too small to be visible.

This is because the arrowhead sizes are by default given as a fraction of the image width. Your image is very narrow (and would be even narrower for just Graph[{1 -> 2}]), so the arrowheads become tiny.

Yes, this is not very good design and it's very annoying.

Unfortunately in Mathematica there's no good way to accurately specify the arrowhead size independently of the image width. Here's the relevant question:

The only way is through specifications such as Large, Small, etc., but these are not numeric, and it's sometimes limiting not being able to give more precise values.

So the workaround is:

Graph[{1, 2, 3}, {1 -> 2, 3 -> 3, 3 -> 1}, EdgeStyle -> Arrowheads[Medium]]

Mathematica graphics

You can reliably check if a graph is directed using DirectedGraphQ and UndirectedGraphQ, but note that graphs with no edges are considered both directed and undirected at the same time in Mathematica. Mixed graphs are considered to be neither.

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263