1
$\begingroup$

I have a Graph object x such that

GraphLayout /. AbsoluteOptions[x]

evaluates to Automatic.

I want generate an object y from x such that

GraphLayout /. AbsoluteOptions[y]

evaluates to the string "RadialEmbedding".

In principle, I imagine that y could be generated from x in a way that leaves x unchanged. Alternatively, y could be an "in-place mutation" of x. I'm interested in both approaches. (If "in-place mutation" is the only convenient way to produce the desired y, then I'd like to know how to "clone" x, so that I can mutate the clone and leave x unaffected.)

PS: I spent a huge amount of time poring over the Mathematica documentation in search for the answer to this question, obviously without any success. I'd be curious to know what keywords I could have used in my search to find the answer.

$\endgroup$
  • $\begingroup$ It's no wonder you couldn't find it easily. Graph functionality is a muddy terrain. There are a few superimposed ways to define graphs and the docs aren't clear at all. $\endgroup$ – Dr. belisarius Oct 28 '14 at 12:58
  • 1
    $\begingroup$ Read carefully this instead of rollingback. $\endgroup$ – Öskå Oct 28 '14 at 12:59
  • $\begingroup$ @belisarius: actually, I approached the question generally, from the standpoint of modifying an arbitrary option in an arbitrary object. I thought that this would be an easy-to-find topic. I was wrong. $\endgroup$ – kjo Oct 28 '14 at 13:00
  • $\begingroup$ @kjo Graphs are very particular objects! $\endgroup$ – Dr. belisarius Oct 28 '14 at 13:03
  • $\begingroup$ @belisarius: Thanks for the tip; I'll keep that in mind from now on. $\endgroup$ – kjo Oct 28 '14 at 13:04
2
$\begingroup$

You can do both:

Generating a second Graph:

x = PathGraph[Range[20]];
GraphLayout /. AbsoluteOptions[x]
y = SetProperty[x, GraphLayout -> "RadialEmbedding"];
GraphLayout /. AbsoluteOptions[y]

(*
Automatic

"RadialEmbedding"

*)

Modifying the property:

PropertyValue[x, GraphLayout] = "RadialEmbedding";
GraphLayout /. AbsoluteOptions[x]

(*
"RadialEmbedding"
*)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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