Orthogonal edges layout in graphviz - layout

I'm traying to use graphviz to generate orthogonal graphs:
graph G {
layout=neato
splines=ortho
A1 [ pos="1,1!" ]
A2 [ pos="2,1!" ]
A3 [ pos="3,1!" ]
A4 [ pos="4,1!" ]
Ae [ pos="5,1!" style=invis]
B1 [ pos="6,6!" ]
B2 [ pos="6,5!" ]
B3 [ pos="6,4!" ]
B4 [ pos="6,3!" ]
C1 [ pos="1,8!" ]
C2 [ pos="2,8!" ]
C3 [ pos="3,8!" ]
C4 [ pos="4,8!" ]
A1 -- C1
A2 -- C2
A3 -- B3
A4 -- B4
C3 -- B2
C4 -- B1
}
which produces following:
orthogonal graph
My questions are:
Is it possible to generate similar layout whithout neato and hardcoded node positions?
How to force edges connected to A3, A4, C3, C4 to be so perfectly aligned to the middle of node as in the cases of A1, A2, C1, C2, B1-4 ?
How to surround A1-4, C1-4, B1-4 into three boxes without changing the layout? (I've tried subgraph clusters but they seem to be not supported by the neato layout; HTML Tables are the option however they seem to be not so perfect in line joining to the cells - ports)
Is it possible to remove the invisible "Ae" node and save the present layout? (when I just remove "Ae" some edges change their layout...)

First, it seems that there are not pos attribute for edge in neato engine or other engines. I follow this answer to solve this question. using a point shape with (width attribute 0) to control the edge.
a code example as follow:
digraph {
graph [bgcolor=white size="5.0,6.66!"]
node [fixedsize=true]
P1 [label=hello fontname=FangSong pos="2.604,4.583!" shape=rect]
P0 [label=graphviz fontname=FangSong pos="0.521,5.625!" shape=rect]
point1 [label="" fontname=FangSong pos="1.562,5.625!" shape=point width=0]
point2 [label="" fontname=FangSong pos="1.562,4.583!" shape=point width=0]
P0 -> point1 [arrowhead=none]
point1 -> point2 [arrowhead=none]
point2 -> P1 [arrowhead=normal]
}
the figure is :

for 1.) no
for 2.) just use pos
for 3.) Please show your tries, so we can perhaps elaborate on this.
for 4.) no
Perhaps you try to use graphviz like an UML-Modelling- or Visio-Tool. In the core graphviz is more for creating the layout as an output, less for consuming layout information as input.

Related

Excel plotting airfoil curves from a paper, faulty polynom?

I'm trying to plot airfoil camber lines in excel, given the polynomial and some constants.
Here is the given data, the final to reach is on the right top, with the (x,y) coordinates being used to create a CAD model of a wing that will be used for a 3-bladed wind turbine rotor.
For the moment I get this:
Is there a fault in the given polynomial?
It looks like the authors reported the a parameters in reverse order. What was reported as a0 is in fact a3, reported a1 is a2, reported a2 is a1 and reported a3 is a0. To give a specific example, the parameters when z' = 10 mm should be
a0 = -0.8E-03
a1 = -8.44E-01
a2 = 2.99E-02
a3 = -3E-04
and the equation when z' = 10 mm should be
y' = yLE + [-0.8E-03]*(x'-xLE)^0 + [-8.44E-01]*(x'-xLE)^1 + [2.99E-02]*(x'-xLE)^2 + [-3E-04]*(x'-xLE)^3
Note that the parameters as reported are multiplied by scale factors (e.g. 10^4) and you need to divide the reported values by those scale factors to get the true values.
Here's my graph of the airfoil profiles
This could have happened if the authors used Excel's LINEST function to do data fitting, because LINEST reports curve fit parameters in high-to-low order (a[n], a[n-1], ... a[2], a1, a[0]). To me this is ordering counter-intuitive and can lead to confusion.
Hope that helps

Excel Formula to copy cell value to a column based on condition

I'm looking to reformat my spreadsheet. Here's a small model of it:
[ ][;9][10][ ]
[ ][ ][X1][Y1]
[ ][ ][X2][Y2]
[ ][;9][20][ ]
[ ][ ][X3][Y3]
[ ][ ][X4][Y4]
[ ][ ][X5][Y5]
[ ][;9][43][ ]
[ ][ ][X6][Y7]
How can I reformat it to look like this:
[ ][;9][10][ ]
[10][ ][X ][Y ]
[10][ ][X2][Y2]
[ ][;9][20][ ]
[20][ ][X3][Y3]
[20][ ][X4][Y4]
[20][ ][X5][Y5]
[ ][;9][43][ ]
[43][ ][X6][Y7]
I was looking to use the if statement, but I'm not sure how to do two things:
1) include the empty cell before the ;9
2) update the value in the left most cell every time the value after the ;9 updates (it should include this value instead)
UPDATE: So I've been trying the answers, but it gives me an error. It turns out I have an extra line in my spreadsheet I didn't notice before.
So I'm trying this and it's close to working. However, I'm actually looking for it to change dynamically if C1 changes number.
This works at the beginning:
But not after the value changes. Here, it should have the value 22584:
This doesn't work either:
With the top ;9 in B1, put this into A1,
=IF(ISBLANK(B1), LOOKUP(1E+99, C$1:C1), "")
Then fill down as necessary.
        
Your revised question might be better answered with the following in A1,
=IF(ISBLANK(B1), INDEX(C$1:C1, AGGREGATE(14, 6, ROW($1:1)/(B$1:B1=";9"), 1)), "")
I think it is more reliable (for cases when X and Y are numbers).
In A1: =IF(ISBLANK(B1),LOOKUP(";9",$B$1:B1,$C$1:C1),"") and fill down.

using boolean array indexing in numpy causes ValueError

I was trying out indexing using boolean arrays
def boolean_array_indexing_each_dim1():
a = np.array(
[
['a','b','c','d'],
['e','f','g','h'],
['i','j','k','l'],
['m','n','o','p']
]
)
print('a=\n',a.shape,'\n',a)
b1 = np.array([True,True,True,False]) #gives error
#b1 = np.array([True,False,True,False]) #works
print('b1=\n',b1.shape,'\n',b1)
b2 = np.array([True,False,True,False])
print('b2=\n',b2.shape,'\n',b2)
selected = a[b1,b2]
print('selected=\n',selected.shape,'\n',selected)
the array b1 = np.array([True,True,True,False]) causes a 'ValueError shape mismatch: objects cannot be broadcast to a single shape'
The array b1 = np.array([True,False,True,False]) however works and produces a result ' ['a' 'k']'
why does this error happen? can someone please tell ?
The reason is your first b1 array has 3 True values and the second one has 2 True values. These are equivalent to indexing by [0,1,2], [0,2] respectively. Numpy's indexing "works" by constructing pairs of indexes from the sequence of positions in the b1 and b2 arrays. For the case of [0,1,2], [0,2] it constructs index pairs (0,0), (1,2) but then there's no partner for the final 2 in b1, so it raises ValueError. Your alternate b1 works because it happens to have the same number of True values as your b2.
I suspect what you intended to accomplish is
selected = a[b1,:][:,b2]
This would consistently slice the array with b1 along axis 0, and then slice it with b2 along axis 1.

Can I use a decision tree to compare values for pairs of attributes?

I would like to use a decision tree for binary classification. I would like to know if my approach is a valid approach for decision trees.
Each instance in my data set has pairs of attributes, and I have identified that for some pairs, I can compare the values to make a decision. For example, an instance may have the following attributes:
instance = {A1, A2, A3, A4, B1, B2, B3, B4}
A1 and B1 have different values, but refer to the same feature--this is that I meant when I referred to them as a pair. What I would like to do is have nodes in the tree that compare values of a pair:
(A1 > B1)
/ \
(A2 < B2) (A3 > B3)
/ \ / \
...
Is this a valid approach using decision trees?
Is there a better learning approach for this type of problem?
This is a valid approach indeed. All you need is to create new binary features like
C[i] = 1 if A[i] > B[i] else 0
or just
C[i] = A[i] - B[i]
and feed them to an ordinary decision tree algorithm, like rpart in R on sklearn.tree.DecisionTreeClassifier in Python.

Find intermediate color

I have 2 colors #DCE7FA and #CADBF7. Want the intermediate color(a kind of Arithmetic mean).
Hexadecimal arithmetic median does not work.
How to proceed?
Yes the normal hex median wont work.. !!
try spliting to to R, G , B and find individual medians..
r1 = DC ; r2 = CA
g1 = E7 ; g2 = DB
b1 = FA ; b2 = F7
now find individual medians..
now,
r3 = (r1+r2)/2 = D3 ;
g3 = E1
b3 = F5
now ur intermediate color = #D3E1F5..
Found an online tool:
http://www.colortools.net/color_combination.html

Resources