When having nodes of different sizes, edges with arrows enabled are not guaranteed to connect with nodes. How to fix that? - networkx

nx.draw_networkx_edges allows for only single value of node_size . The issue with that is that my nodes have different sizes. It means that if I'll set the edge's node_size to the "target" node's size, it will be mismatched with the "source" node's size. If the "target" is larger than the source, the edge will not be connected with the source node because it'll assume that it's bigger than it is. Is there any way to have an arrow connected with the border of both nodes if these nodes are of different sizes?
See:

Yes - use an array as your node_size argument for nx.draw_networkx_edges rather than a scalar. Contrary to your question, the function does accept multiple values:
node_size : scalar or array (default=300)
Size of nodes. Though the nodes
are not drawn with this function, the node size is used in determining
edge positioning.
The order of the nodes in the node_size array are given by the optional parameter nodelist. If this is not specified, the default is G.nodes().

Related

Resource layout creation in Anylogic

I am using creating my equipments as resourcepools which are created within a rectangular node as a zoning region. During the model run I will increase or decrease the equipment quantity using a slider. I have set the settings to destroy the units when capacity is reduced (as guided in this thread Removing agent when resourcepool capacity reduced). However, after reducing the capacity, the first few rows of resources are destroyed and when the capacity is increased again, new equipments are built from the last row within the node, leaving the first few rows permanently empty. How can I rearrange the layout to always fill up the empty regions first?
You need to take control of positioning the agents yourself. Use the "on unit creation" code box to 'unit.setXY(...)' and position them where needed. Note that AnyLogic does also not care about positioning agents on top of each other. So if you want to have a concept of "this space is taken" you need to model that explicitly as well, best via a custom agent type itself.

Arrange containers based on weight in different levels of PalletRack in Anylogic

I have an agent Container and it has a parameter: weight. The parameter weight draws its values from a custom distribution(mentioned below 1). Now, I want to arrange the containers based on its weight in the pallet racks. The heavier ones should go to the bottom levels of pallet rack and lighter ones should be at the top. The properties of my palletRack is also mentioned below 2. What should I write in Pallet Rack/Rack System field of rackStore block in order to achieve this? Or if there is some other way to do this please let me know.
As of now, I am arranging the containers on the basis of other two parameters: carrier & type. I want to add this additional criteria of weight. I have mentioned my current rackStore properties here. rackStore-properties
This is the current code in Pallet Rack/Rack System field :
(agent.carrier==Truck && agent.type==C20 ? palletRack4 : (agent.carrier==Truck && agent.type==C40 ? palletRack6 :(agent.carrier==Train && agent.type==C20 ? palletRack5 :palletRack7)))
Thank you in advance for your help!
weightDistribution
palletRack-properties
I am placing the container in a particular cell of the palletRack(i.e. with a given value for row, position & level).The row and position is defined as parameters of the agent Container. The level depends on the weight parameter of Container which is defined using a function. The values of row, position & level mentioned in rackStore properties can be found here: rackStore properties.
Here, agent.row= uniform_discr(0,1) as we have only two rows for a 2 rack 1 aisle palletRack. agent.position= uniform_discr(0,9) as the palletRack has 10 cells.
The function getLevel can be found here: function body
This approach assigns containers in a particular weight range to a particular level in the palletRack, but I would like it to be more generic such that, if the incoming container can be stored on any level, provided the containers below it are heavier.

tableau adjust marks size using number

In Marks, click Size and there pops a slider where I can adjust the size of a shape. But how to accurately control the size, is there some property with numbers to accurately control it? I have two sheets to show something similar and I want to display exactly the same sized shapes.
If you want to ensure 'sizes' are the same across two worksheets, I'd suggest snapping the 'size' setting to the center on both, as this is the easiest option to select. You can then use a measure to set the size, if this is desirable, and then the difference in size will be relative on both worksheets.
There isn't a numerical value override for the size slider.
Ben is correct, there isn't yet a numerical value override for the slider. You can use parameters with Min/Max/Sum etc. and a variable to somewhat change the sizes but they have to have multiple entries per line. It is unfortunate that Tableau still doesn't get that people want both a 'relative' sizing system that uses numbers from the dataset and a 'static' sizing system that allows for shapes to be set to '11px' or something along those lines. Yes, you can control that kind of in the dashboard with a vertical and fill entire box etc; but that doesn't address the very real scenario where you want a user to be able to re-size on the fly. Just my two cents.
I ran into this today. Very annoying. Need to keep shapes the same size across all worksheets and therefore same on dashboard.

vis.js fixed length edges

Is it possible to give an edge a fixed length? Even if I set the length of individual edges, physic engine changes it.
I am trying to visualize 3 clusters, each with couple hundred of nodes. There is an option to aggregate the cluster into couple of nodes. I want to connect these aggregated nodes with really short edges and give these nodes high mass so they will repulse other clusters like they were doing when they had hundreds of nodes.
It seems like the answer to this question these days is YES! The network/edges visjs.org docs describe a "length" option:
"The physics simulation gives edges a spring length. This value can
override the length of the spring in rest."
So when you're setting up your edges you might do something like this to make an extra long edge:
myEdges.push({from:'nodeid1', to:'nodeid2', length:300});
The length by default is about 95 I think, so a length of 300 would be about three times the normal.
If you want to change the default edge length (not including any which you've set explicitly on edges) then this is the 'springLength' of the network, so pass an option while making the network:
var network = new vis.Network(container, data,
{"physics": {"barnesHut": {"springLength":100, "springConstant": 0.04}}}
);
The physics engine might constrain things and sort of hide the changes you're trying to see, so you may also need to tweak things like 'springConstant'.
It's not possible to set a fixed length. You can play around though with the default springLength and springConstant though, checkout the docs on physics:
http://visjs.org/docs/network/physics.html

Swift SKSpriteNode draw order

I have some problems with SKSpriteNode. If I do this:
var node1=SKSpriteNode(imageNamed:"image1");
var node2=SKSpriteNode(imageNamed:"image2");
self.addChild(node1);
self.addChild(node2);
Then image2 will appear in front of image1 (and that is good).
But if I do this:
var node1=SKSpriteNode(imageNamed:"image1");
var node2=SKSpriteNode(color:UIColor.redColor(),size: CGSizeMake(0,0,300,300)));
self.addChild(node1);
self.addChild(node2);
Then image1 will appear in front of node2-rectangle. Why does it do that?
I’m surprised that even compiles—CGSizeMake should only take 2 arguments (width, height), as opposed to CGRectMake, which takes 4 (x, y, width, height). In other words, it looks like you’re creating node2 with a size of (0,0). Try …size:CGSizeMake(300,300) instead.
From Apple's documentation...
The default value (of SKView's ignoreSiblingOrder property) is NO, which means that when
multiple nodes share the same z position, those nodes are sorted and
rendered in a deterministic order. Parents are rendered before their
children, and siblings are rendered from eldest to youngest. When this
property is set to YES, the position of the nodes in the tree is
ignored when determining the rendering order. The rendering order of
nodes at the same z position is arbitrary and may change every time a
new frame is rendered [emphasis added].