15
$\begingroup$

Is a list of all graph layouts available?
For example I want to check all the layouts at once for a specific graph so I'll map this over the list.
Of course you can just type the list yourself but that I'm interested in getting all the layouts in an easier way.

Graph[{e1, e2, ...}, GraphLayout -> #] & /@ layoutList

enter image description here

$\endgroup$
1

2 Answers 2

17
$\begingroup$
ResourceFunction["QueryCodeCompletion"]["GraphLayout","KernelSymbol","Graph","InOptionValuePosition"]

enter image description here

$\endgroup$
1
  • 2
    $\begingroup$ It's good to mention that these strings include explicit quotation marks. The quotes must be removed before these can be used with the GraphLayout option. $\endgroup$
    – Szabolcs
    Jul 25, 2022 at 9:22
11
$\begingroup$

@yode's answer is the better choice, but since it missed some options, here is a manual one that works in this particular case.

The question you asked was discussed during a Live CEOing session (I don't remember the episode). From version 10.2 we have WolframLanguageData which in this particular case, if we assume each option was used in the documentation examples, we can somehow extract them.

The code is:

list1 =
 Cases[Cases[
     WolframLanguageData["GraphLayout", 
      "DocumentationExampleInputs"], {___, "GraphLayout", "\[Rule]", 
       a__} :> ReplaceAll[ToExpression@{a}, Null -> Nothing], 
     Infinity], {a_String, ___} :> a, Infinity] // DeleteDuplicates //
   Sort

(* Out: {"BalloonEmbedding", "BipartiteEmbedding", "CircularEmbedding", 
"CircularMultipartiteEmbedding", "DiscreteSpiralEmbedding", 
"GravityEmbedding", "GridEmbedding", "HighDimensionalEmbedding", 
"LayeredDigraphDrawing", "LayeredDigraphEmbedding", 
"LayeredEmbedding", "LinearEmbedding", "MultipartiteEmbedding", 
"PlanarEmbedding", "RadialEmbedding", "RandomEmbedding", 
"SpectralEmbedding", "SphericalEmbedding", "SpiralEmbedding", 
"SpringElectricalEmbedding", "SpringEmbedding", "StarEmbedding", 
"TutteEmbedding"} *)

@yode answer (\" was removed from options):

yode = StringReplace[
  ResourceFunction["QueryCodeCompletion"]["GraphLayout", 
   "KernelSymbol", "Graph", "InOptionValuePosition"], "\"" -> ""]

(* Out: {"SpringElectricalEmbedding", "SpringEmbedding", 
"HighDimensionalEmbedding", "LayeredEmbedding", 
"LayeredDigraphEmbedding", "BalloonEmbedding", "RadialEmbedding", 
"SpiralEmbedding", "BipartiteEmbedding", "CircularEmbedding", 
"CircularMultipartiteEmbedding", "DiscreteSpiralEmbedding", 
"GridEmbedding", "LinearEmbedding", "MultipartiteEmbedding", 
"PlanarEmbedding", "StarEmbedding", "SpectralEmbedding", 
"TutteEmbedding", "GraphLayout", "Graph"} *)

Comparison

(* options exist in yode but not in list1 *)

Complement[yode, list1]

(* Out: {"Graph", "GraphLayout"} *)



(* options exist in list1 but not in yode *)

Complement[list1, yode]

(* Out: {"GravityEmbedding", "LayeredDigraphDrawing", "RandomEmbedding", "SphericalEmbedding"} *)

An interesting point is that all the options end with Embedding except "LayeredDigraphDrawing" (the option used in an example in the "LayeredDigraphEmbedding" section).

$\endgroup$

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.