Message Boards Message Boards

0
|
1810 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

CreateDataStructure visualization object not rendering as image or graphics

Posted 1 year ago

I've been messing around with the CreateDataStructure function and generating binary trees. However, the tree gets enormous, and the built-in parameter "visualization" creates an image or graphic that needs to be resized to visualize the tree correctly. I attempted to use the ImageResize function to do this but was thrown an error.

CreateDataSructure - creates a data structure with the specified type. https://reference.wolfram.com/language/ref/CreateDataStructure.html

The specified type is BinaryTree https://reference.wolfram.com/language/ref/datastructure/BinaryTree.html

You can then interact with this variable and do other calls on it. For instance, "Visualization" generates a 'visualization'. Except this call doesn't output anything that can be manipulated with ImageResize. An error that it's not an image or graphic pops up. The binary tree I am generating is too large for this, and I would like to adjust the image size so that it can fit on an 8.5" x 11" printout.

Here is the function. https://reference.wolfram.com/language/ref/ImageResize.html

binaryTree2 = CreateDataStructure["BinaryTree", "0"]; 
binaryTree2 = growTree[gameTree2]; 
binaryTree2["Visualization"]

output from binaryTree2

This is the output from the visualization call onto binarytree2. I get an error when using the same call in ImageResize.

In[25]:= ImageResize[gameTree2["Visualization"],100]

During evaluation of In[25]:= ImageResize::imginv: Expecting an image or graphics instead of .
Out[25]= ImageResize[,100]

Here is what the output actually looks like. enter image description here

I have also attempted to right click the image and convert it to graphics and get the following error.

Set::write: Tag Inherited in Inherited[State] is Protected.
POSTED BY: Ziggy Stardust
2 Replies

Hi Ziggy,

"Visualization" generates a Graph.

ds = CreateDataStructure["BinaryTree", 1 -> {2 -> {5, Null}, 8}];
viz = ds["Visualization"]

Head@viz
(* Graph *)

Any Graph / Graphics options can be applied to it

Graph[vis,
 ImageSize -> {200, 200},
 AspectRatio -> 1/2,
 VertexShapeFunction -> "Square",
 VertexSize -> .15,
 VertexStyle -> Red,
 VertexLabels -> "Name"]
POSTED BY: Rohit Namjoshi

Thank you! I'm now able to change the size of the graphic so I can print it on an 8.5 x 11 piece of paper. I'm only having one more problem. I want to increase the size of the vertices and nothing appears to happen when I'm using the VertexSize option. It looks like the edges are changed but not the actual vertex.

Graph[binaryTree2["Visualization"], ImageSize -> {2550, 3300}, VertexSize -> Large, EdgeStyle -> {Thick}]

https://reference.wolfram.com/language/ref/VertexSize.html

As you can see the vertices are very small. It only looks like the adjustment in size is effecting the edges. This is the same graph as the picture in my original post.

enter image description here

POSTED BY: Ziggy Stardust
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract