4
$\begingroup$

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?

$\endgroup$
1
  • $\begingroup$ even with Grafo1=Graph[{1,2,3},{1->2, 3->3, 3->1}, DirectedEdges->True] i got the same graph. $\endgroup$
    – asdf
    Jun 30, 2015 at 14:05

1 Answer 1

9
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ Ah, good. I don't have to write it up. $\endgroup$
    – rcollyer
    Jun 30, 2015 at 14:11
  • $\begingroup$ lulz, thank you! :D $\endgroup$
    – asdf
    Jun 30, 2015 at 14:12
  • $\begingroup$ @rcollyer Though an arrowhead size specification in (numerical) absolute units would be really-really useful, if that can be arranged :-) $\endgroup$
    – Szabolcs
    Jun 30, 2015 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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