Group Abstract Group Abstract

Message Boards Message Boards

0
|
10K Views
|
3 Replies
|
5 Total Likes
View groups...
Share
Share this post:

How to construct graphs programmatically

Posted 11 years ago
POSTED BY: Erik Itter
3 Replies
Posted 11 years ago

sorry, just realized that I forgot to thank you (both), this solution was pretty much doing the job and easy to make it do the whole way.

POSTED BY: Erik Itter
Posted 11 years ago

I post this for illustrative purposes (if I have understood underlying aim correctly).

f[n_] := {DirectedEdge[##], Boole[Divisible[##]]} & @@@ Tuples[Range[2, n], 2]
g[n_] := With[{ds = Transpose@f[n]},
           Graph[##, 
           VertexLabels -> Thread[Range[2, n] -> (Placed[Framed[#, Background -> White], Center] & /@ 
           Range[2, n])],
           VertexLabelStyle -> Red, 
           EdgeLabels -> "EdgeWeight",
           EdgeStyle -> MapThread[Function[{u, v}, u -> {RGBColor[v, 0, 0], Thickness[0.005 + v 0.005]}], {#1, 
           ds[[2]]}]] & @@ ({#1, EdgeWeight -> #2} & @@ ds)]

Using:

Grid[Partition[g /@ Range[2, 10], 3], Frame -> All]

enter image description here

POSTED BY: Mark Dooris
Posted 11 years ago
POSTED BY: Bill Simpson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard