BST: When inserting a node into a red-black tree, in which direction are the nodes rotated? - binary-search-tree

I am learning about binary search trees, and I am trying to wrap my head around red-black trees at the moment. I don't understand the direction of rotation for red-black trees: If a node is inserted to the left of a parent (which I assume would have no children), would it be rotated to right? Or in a more general sense, whenever a node is inserted to the right or left of parent with no children, would the node and parent be rotated to the opposite direction?

Related

Dynamically show another graph within a node in Cytoscape.js

I'm using Cytoscape.js to visualize a large, nested data structure. Showing the whole graph directly makes it hard to interpret, so I'm only showing the top-level nodes at first. Then, when a node is clicked, I want to show the subgraph within the node.
My first attempt was to just add the subgraph as child nodes. The child nodes initially have visibility: hidden, but are shown once their parent node has been selected (the parent node itself also changes its appearance a bit when this happens, to indicate it has received the focus). This works, somewhat. However, the top-level nodes are drawn very large, obviously since they now contain their hidden child nodes.
So my alternative solution would be to dynamically add the child nodes at the moment when their parent receives focus. However, this would probably require some additional restrictions on Cytoscape, as I don't want the parent node to grow or move when this happens. So basically the node bounds of the parent becomes the canvas in which the child graph should be drawn.
My double questions is then (1) whether Cytoscape can actually introduce such constraints, and (2) if this is really the best solution for this particular problem.

Cytoscape.js Yfiles orthogonal edges

Can we use Yfiles with cytoscape.js to render orthogonal edges. My layout is a preset layout of compound nodes. I want the child nodes of the compound node to connect via orthogonal edges to other nodes.
I actually don't know what you mean with "yfiles with cytoscape.js". But if you want to do orthogonal edges with cytoscape.js maybe have a look here.
If this doesn't answer your question maybe give some example.

Cytoscape.js connect two parent nodes to a child node

Is there a way in Cytoscape.js to connect two parent nodes to a child node like the example in the picture?
Sorry if the question is something very basic but I couldn't find it in the documentation (maybe I have missed it).
All I could do was to create an edge between one parent and the child and another edge between the other parent and the child, which looks kind of messy and won't help me in the visualization of a family tree.
Use segments edges to draw edges made of multiple straight lines: http://js.cytoscape.org/#style/segments-edges

Layout for Cytoscape (JavaScript) Compound Nodes Makes "Containers" Too Large

How can I make the "container" nodes in a Cytoscape Compound Graph smaller? The "cose" layout makes them gigantic for my graph, wasting an extreme amount of space. How can I "style" such container nodes to be a more reasonable size for the "child" nodes contained within it?
The size of compound parent nodes is a function of the position and dimensions of its child nodes. Thus, you can control parent node size via layout. You can try experimenting with the parameters of the existing layouts or you can even write your own.
In general, you have to experiment with the parameters of a layout to get the visual results you want. It can not be done automatically on the layout side.

Cytoscape.js - Is there a way to draw edges on top of compound nodes?

I'm trying to figure out a style/selector that could be applied globally to make edges draw on-top-of compound nodes using cytoscape.js. I understand the value of having regular nodes always on-top-of edges but was wondering if there is a way to work around this with compound nodes?
Edges connecting to, from, or inside compound nodes are drawn on top of the associated compound nodes. Unrelated edges are drawn behind, as usual. You can control draw order with z-index, but those values are used relatively according to the hierarchy created by the previous rules.
It sounds like your graph has nodes placed too closely together. Have you tried adjusting the CoSE layout options for your graph?