0
$\begingroup$

Consider the following graph: vertices are integers between $1$ and $n,$ where $a$ is connected to $b$ if $a$ divides $b.$ This is easily constructed in Mathematica thus:

divGraph[n_] := 
 With[{pairs = Subsets[Range[n], {2}]}, 
  With[{divis = Select[pairs, Mod[#[[2]], #[[1]]] == 0 &]}, 
   Graph[Apply[Rule, #] & /@ divis, VertexLabels -> "Name"]]]

OK, let's now look at divGraph[8]:

divGraph[8]

You will notice that you cannot see the edge connecting $1$ to every other vertex, though we all know there should be such an edge. Is this a bug? Can it be worked around?

PS: If you are curious about why one might want to look at such a thing, see this MO question.

$\endgroup$
3
  • 2
    $\begingroup$ Which edge is missing (besides 1$\to$1)? $\endgroup$ Sep 12, 2017 at 23:45
  • $\begingroup$ Yeah.... What's the problem? $\endgroup$ Sep 13, 2017 at 0:45
  • 2
    $\begingroup$ an alternative way to define divGraph : divGraph[n_] := RelationGraph[UnsameQ @ ## && Divisible[#2, #]&, Range @ n] $\endgroup$
    – kglr
    Sep 13, 2017 at 1:28

1 Answer 1

3
$\begingroup$

I'm not sure what edges you're having trouble seeing.

To highlight the edges connecting 1 to everyone else you can use Highlight.

divGraph[8]~ HighlightGraph ~ (1 -> # & /@ Range[2, 8])

enter image description here

Maybe you'll like the layout better of:

Graph[divGraph[8], GraphLayout -> "RadialDrawing"] // 
 HighlightGraph[#, 1 -> # & /@ Range[2, 8]] &

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ Hmm. Perhaps temporary blindness, but on the other hand, the radial drawing looks way better, so I am glad I asked! $\endgroup$
    – Igor Rivin
    Sep 13, 2017 at 0:58

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.