Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Let $G$ be a simple undirected graph. Let the set of vertices be $V=\lbrace 1, 2, 3, 4, 5, 6, 7, 8, 9, 10\rbrace $, and let the edges set be $E=\lbrace (a, b): a\text{ divides }b\text{ or }b\text{ divides }a;\text{ and }a\neq b~\forall a, b\in V\rbrace $.
$\begingroup$A very similar question is answered in the documentation for RelationGraph. Here's one way to do it: RelationGraph[ Unequal[#1, #2] && (Divisible[#1, #2] || Divisible[#2, #1]) &, Range[10], VertexLabels -> "Name"] - note if you use CoprimeQ instead of both Divisibles then 1 is not handled quite the same.$\endgroup$
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
RelationGraph
. Here's one way to do it:RelationGraph[ Unequal[#1, #2] && (Divisible[#1, #2] || Divisible[#2, #1]) &, Range[10], VertexLabels -> "Name"]
- note if you useCoprimeQ
instead of bothDivisible
s then 1 is not handled quite the same. $\endgroup$