GraphViz fixedsize=shape not working - graphviz

The node property fixedsize=shape does not seem to be working on my GraphViz graphs. For example, this:
digraph Automaton {
rankdir=LR
node [shape=circle fixedsize=shape label=""]
0;
1 [shape=doublecircle];
2 [shape=doublecircle label="HELLO_12345"];
0 -> { 2 } [label="98 (b)"];
0 -> { 1 } [label="97 (a)"];
1 -> { 1 } [label="97 (a)"];
}
...produces this:
I expected the node labeled HELLO_12345 to be drawn the same size as the other nodes. I tried adding fixedsize=shape to the declaration of that node, to no avail.
When was fixedsize=shape added? The latest version of GraphViz appears to be 2.38, but Ubuntu 14.04 is still at version 2.36.

Turns out GraphViz has a change log. Who'da thought? And yes, fixedsize=shape was added after version 2.36.0 and before version 2.38.0. I don't know what the intermediate version that contained this change was called (the log doesn't say) but this probably explains why it doesn't work on Ubuntu 14.04.

Related

How to change font size of a single record item in Graphviz

I'm trying to create a state chart from Graphviz of type record. Please check the reference here.
So here is the basic code:
digraph lamp {
node [shape=point,label=""]ENTRY
node [style=rounded shape=record ]
ON [label="{On| Some code here}"];
OFF [label="{Off| Some code here}"];
ENTRY -> ON[label="Initialization"]
ON -> OFF[label="|toggle|"]
OFF -> ON[label="|toggle|"]
}
In above code, I need to add some code below the state name like On and Off where I put the line Some code here. Since there will be a code and it can be any number of lines, I like to change the font size of this single record block where I will put the code (Not the state name record).
So in this line of code:
ON [label="{On| Some code here}"];
I like to change the font size of Some code here only not of On.
So, How can I get the control to independently change styling like font size or font name etc of the entered code here?
You can use html-like text, without building tables. (https://www.graphviz.org/doc/info/shapes.html#html). Like so:
digraph lamp {
node [shape=point,label=""]ENTRY
node [style=rounded shape=record ]
ON [label=<{<FONT COLOR="RED" POINT-SIZE="24.0">On</FONT>|<FONT COLOR="darkgreen" POINT-SIZE="10.0"> Some code here</FONT>}>];
OFF [label=<{<FONT COLOR="black" POINT-SIZE="24.0">Off</FONT>|<FONT COLOR="darkred" POINT-SIZE="10.0"> Some code here</FONT>}>];
ENTRY -> ON[label="Initialization"]
ON -> OFF[label=" |toggle| "]
OFF -> ON[label=" |toggle| "]
}
Giving:

Facing warning: "Nic is not connected to any gates!" in VEINS simulation

I'm using Veins 5.0, OMNet++ 5.5.1, SUMO 1.2.0
I'm getting the following warning in my simulation:
WARN (PhyLayer80211p)mpsScenario.node[0].nic.phy80211p: Nic is not connected to any gates!
This is how my mpsScenario.ned file looks:
import org.car2x.veins.base.connectionManager.ConnectionManager;
import org.car2x.veins.base.modules.BaseWorldUtility;
import org.car2x.veins.modules.mobility.traci.TraCIScenarioManager*;
import org.car2x.veins.modules.obstacle.ObstacleControl;
import org.car2x.veins.modules.world.annotations.AnnotationManager;
import org.car2x.veins.nodes.Car;
import org.car2x.veins.mps.traffic.BaseTrafficManager;
network mpsScenario {
parameters:
double playgroundSizeX #unit(m); // x size of the area the nodes are in (in meters)
double playgroundSizeY #unit(m); // y size of the area the nodes are in (in meters)
double playgroundSizeZ #unit(m); // z size of the area the nodes are in (in meters)
string trafficType;
#display("bgb=$playgroundSizeX,$playgroundSizeY");
#figure[description](type=text; pos=700,30; font=,,bold;
text="Aerolink(TM) Misbehavior Protection System Simulation");
submodules:
obstacles: ObstacleControl {
#display("p=240,50");
}
annotations: AnnotationManager {
#display("p=260,50");
}
connectionManager: ConnectionManager {
parameters:
#display("p=150,0;i=abstract/multicast");
}
world: BaseWorldUtility {
parameters:
playgroundSizeX = playgroundSizeX;
playgroundSizeY = playgroundSizeY;
playgroundSizeZ = playgroundSizeZ;
#display("p=30,0;i=misc/globe");
}
manager: TraCIScenarioManagerForker {
parameters:
#display("p=115,60");
}
trafficManager: <trafficType> like BaseTrafficManager {
#display("p=115,0");
}
node[0]: Car {
}
connections allowunconnected:
}
which is basically the default file with one custom trafficManager module. Also, the manager points to TraCIScenarioManagerForker.
The Car.ned module is same as default that is provided by VEINS 5.0.
Since mostly everything is default, I don't understand why I am getting the aforementioned warning. Due to this warning I am getting a std::bad_alloc error as soon as a new BSM is received by a vehicle.
Edit 1: Add MWE which is in github repo
My issue can be recreated using the following steps:
Clone my branch v5 from my fork of veins:
git clone --branch v5 https://github.com/raash1d/veins
Start OMNeT++
Run the simulation from scenarios/mps/omnetpp.ini; choose "Gui" Config name.
Click "RUN" and observe the log messages in OMNeT++ Qtenv window. As soon as a vehicle is created, a warning is generated for the Nic module.
This eventually causes the std::bad_alloc error.
Your OMNeT++ simulation playground is configured (in omnetpp.ini) to go from (0,0) to (10000,10000).
Your SUMO road network (in .net.xml) goes from 0.00,0.00 to 5527.41,7491.84 (this is okay), but your SUMO buildings (in .poly.xml) go from -3255.66,-3540.81 to 5794.35,8029.21.
This means that your simulation will try to use buildings that are outside the playground, which crashes it. You will need to increase the size of the simulation playground.

How to change the interpolator(s) on a Roku Scenegraph animation node?

Taking an example from the Roku SDK docs:
<Animation id="transAnimation"
duration="1"
repeat="true"
easeFunction="linear" >
<Vector2DFieldInterpolator id = "myInterp2"
key="[0.0, 1.0]"
keyValue="[ [640.0, 320.0], [100.0, 100.0] ]"
fieldToInterp="myPoster.translation" />
</Animation>
After I've done a find on "transAnimation" is it possible to change the interpolator in brightscript code? There are interpolators present in the XML, but after the scenegraph is built they no longer appear as children of my animation node.
Yes you can do that, find the interpolators with m.top.findNode and modify the reverse value like so
myInterp2 = m.top.findNode("myInterp2")
myInterp2.reverse = true
Assuming this is a toggle-able item you'll need to unset the reverse in the original animation:
myInterp2 = m.top.findNode("myInterp2")
myInterp2.reverse = false
HOWEVER, I just went through this last week and for some reason could not get it to work on Roku 4 despite it having 7.7 (worked fine on 1, 3, and ultra but on R4 it did not reverse?!), so rather than goof around with it for hours I went back to adding a separate animation to handle the reverse.

Highlight output path (decision tree) in d3 tree

Here i'm working on Decision tree using d3 tree example: Search collapse tree. In this example, user can search the node and the path from root to selected node will be highlighted. But in my case, when user enters, the nodes that connects to the output node, the path from the root node to the output node should be highlighted. Just like shown in the image:
I need to work the tree just like shown in the image but my logic seems not working. Please check out my FIDDLE. To get the outputh path, i added a method named as "searchPath" that works on click function of "Find output path" button. (In fiddle, the click function is not working, dont know why. In normal html page it works):
function searchPath(){
var searchText = $("#newpath").val();
//alert(searchText)
var textspl = searchText.split(",");
var path="";
for(var i=0;i<textspl.length;i++){
var paths= searchTree(treejson2,textspl[i],[]);
fullpath.push(paths[Object.keys(paths).length-1]);
}
console.log("finally : ");
console.log(fullpath);
d3.selectAll("circle").filter(function(d) {
console.log("circle name "+d.name);
});
//return fullpath;
}
To select the circle and link element based on the path, i added "id" attributes to those element. For circle, i give id as d.name and for link i give id as d.source.name+":"+d.target.name", so as to easily identify the source node and target node of a particular link.
But now i'm stuck with the code, i'm not getting any idea or logic to go forward.

Text wrapping with dot (graphviz)

I used the code below to create a graphic using dot (graphviz).
digraph
{
node [color=Blue,shape=box]
1.1 [label="Frequency of t exceeds upper threshold"]
2.1 [label="t has d-mutant tiles"]
2.2 [label="Valid"]
3.1 [label="Frequency of t exceeds lower threshold"]
3.2 [label="Frequency of t exceeds lower threshold"]
4.1 [label="Insufficient evidence"]
4.2 [label="Valid"]
4.3 [label="t has only one d-mutant that exceeds lower threshold"]
4.4 [label="Are there any d-mutant tiles with significantly higher frequencies?"]
5.1 [label="Insufficient evidence"]
node [color=Green] 5.2 [label="Correct t to t'"] node [color=Blue]
5.3 [label="t has a d-mutant tile t' that is closer than all other d-mutant tiles and for which a corrected base has a higher quality score"]
5.4 [label="Valid"]
6.1 [label="Insufficient evidence"]
6.2 [label="t' is unique"]
7.1 [label="Insufficient evidence"]
node [color=Green] 7.2 [label="Correct t to t'"] node [color=Blue]
1.1 -> 2.1 [label="no"]
1.1 -> 2.2 [label="yes"]
2.1 -> 3.1 [label="no"]
2.1 -> 3.2 [label="yes"]
3.1 -> 4.1 [label="no"]
3.1 -> 4.2 [label="yes"]
3.2 -> 4.3 [label="no"]
3.2 -> 4.4 [label="yes"]
4.3 -> 5.1 [label="no"]
4.3 -> 5.2 [label="yes"]
4.4 -> 5.3 [label="no"]
4.4 -> 5.4 [label="yes"]
5.3 -> 6.1 [label="no"]
5.3 -> 6.2 [label="yes"]
6.2 -> 7.1 [label="no"]
6.2 -> 7.2 [label="yes"]
}
As you can see, some of the boxes in the graphic have a lot of text in the label. I can insert \n characters to make sure the boxes aren't too wide, but I'm wondering if there is a way I can set the width of the boxes and then have the box labels do a hard wrap. Is this possible?
graphviz doesn't support automatic line breaks. You have to put the \n in manually.
you can set a width and a height to a node and define it as fixedsized - this will
limit the size of the node and draw only as much text as fits into the node
Although graphviz does not support text wrapping by itself,
dot2tex (latex+graphviz) does.
The dot2texi latex package gives an all-in-one solution,
with (from the users point of view) a single call to a single tool to build the graph.
A short example:
\documentclass{standalone}
\usepackage{dot2texi}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
\begin{dot2tex}[dot]
digraph G {
d2toptions ="--autosize"
node [lblstyle="text width=10em,align=center"]
a [texlbl="This text will be automatically wrapped, for example at a fixed width."]
b [texlbl="Manual linebreaks from past century can be avoided!"]
a -> b
}
\end{dot2tex}
\end{document}
This can be compiled invoking for example: pdflatex --shell-escape myFile.tex, the text will be automatically wrapped at the prescribed fixed width.
As a side note, this tool seems a handy workaround for graphviz' limited typesetting control of the nodes contents.
The OP wrote a whole Perl script to achieve this. I found it in his blog: Text wrapping with dot (graphviz).
⚠ Note
This only works if the labels are in the format node [ label=”node label” ]. If the nodes are declared directly (e.g. ”node label”) then it doesn’t work
Perl script:
#!/usr/bin/perl
use strict;
my $usage = "setdotlabelwidth [char-width] < [dotfile]";
my $width = shift() or die("Usage: $usage $!");
while(<STDIN>)
{
if(m/label="(.*?)"/)
{
my $labeltext = $1;
my #words = split(/ /, $labeltext);
my #newtext = ();
my $newline = "";
foreach my $word(#words)
{
if( length($newline) > 0 and
length($newline) + length($word) > $width )
{
push(#newtext, $newline);
$newline = "";
}
$newline .= " " if( length($newline) > 0 );
$newline .= $word;
}
push(#newtext, $newline) if( length($newline) > 0 );
my $newlabel = join("\\n", #newtext);
s/label=".*?"/label="$newlabel"/;
}
print;
}
Save this program as setdotlabelwidth, then simply pipe the output into GraphViz. If for example you want to set the width to 35 characters, then the command is:
./setdotlabelwidth 35 < tile-error-correction.dot | dot -Tpng -o tile-error-correction.png
Before:
After:

Resources