## Hierarchical nodes management

We want to start managing hierarchical relationships between products using (hopefully) boilerplate tree algoritms, datamodel and GUI software (involving Java and Angular).

Verticaly bound products will limit child nodes to have a price higher then a parent (or within a % % upper limit).

Nodes on a same level AND which are manually bound to each other are considered ‘horizontically’ bound and will give the same sales price to each other (according to a ‘horizontal’ rule which uses ‘lowest’ or ‘average’ or ‘most common’ price.

We only support ‘x’ hierarchy levels (like 3 or 4)

Does these type of requirements feel familiar to some one? Can you refer me some existing documentation (database models) or existing software (Java backend and/or angular JavaScript libraries)?

## Hierarchical vs Flat sitemap

I want to create a sitemap for my e-commerce website.

1. Fashion: enter fashion department
2. Fashion > *Women: enter the Women‘s sub-department under Fashion
3. Fashion > women > Shoes -> enter shoes unit under women

With respect to SEO, which is the better way to create a site-map?

So user have 2 ways to navigate to Women‘s sub-department, either directly through Home page or by navigating from Home to Fashion and then to Women page.

## Hierarchical list for selecting an element

The user is trying to select an element which will be used in a form. So it could be like selecting interests in an app where you can pick the more general case (e.g. sports) or the more specific (e.g. baseball).

I have hierarchical data where:
* Exactly one node may be selected.
* Users can select nodes anywhere in the tree
* Leaf nodes must be selectable
* Parent nodes may be selectable. Selecting a parent node represents a selection of all of its leaf node descendants.
* Selectable parent nodes are uncommon.
* The depth of the data is deeper than can be readily shown on the screen all at once.

I am developing an interface for browsing this data. This data needs to be usable on both desktop and mobile interfaces on the web.

I am thinking of modeling an interface after what Apple does with hierarchical menus, like the one below. The differences in my case are primarily that:
* The items can have three states: selectable node, refinable node, and nodes with both capabilities. How do I make this look uncluttered?
* My design must operate reasonably on both desktop and mobile. How do I design the refinement signifier in an unobtrusive way that is clear even on desktop views.
* My lists have a lot of heterogenous content. This happens only rarely in Apple menus, like the shut down button in the second screenshot. How do I show heterogenous content without looking disjoint?

Notice the blue row at the bottom representing differing content.

What I’ve been thinking of so far is similar to the Apple design. These next two screenshots show the top level of the hierarchy here, and…

…the screen after food is selected.

I like the multi-screen approach to this design for my use case, so I am primarily looking for feedback on exactly what icons/buttons to put in, and how to separate out content. I’m particularly interested in examples on the web and high fidelity mock examples, but I’m open to lower fidelity feedback as well.

The one structural thing that I think could be changed is in the combination case where a parent node can also be selected. Conceptually I’ve illustrated it here:

I’d like to draw attention to the fact that this makes the rows less crowded, and seem more homogenous. But I’m not sure exactly how to design the current level selection mechanism. How could I clearly indicate that the current level can be selected? Relatedly, how do I indicate the situation where the current level can’t be selected?

## How to model hierarchical json in Java

I’m a front end developer who is brand new to backend development. My task is to model json in a Java object. It’s just some mock data for now that my controller returns.

{ "data": {     "objectId": 25,     "columnName": [         "myCategory",         "myCategoryId"     ],     "columnValues": [         [             "Category One",             1         ],         [             "Category Two",             2         ],         [             "Category Three",             3         ],         [             "Category Four",             4         ],         [             "Category Five",             5         ]     ] } 

}

And here’s my attempt. The controller returns this json correctly. But isn’t this too simple? What I believe should be done is extrapolate the columnName and columnValues arrays into separate classes but I’m not sure how.

package com.category;  import java.util.List;  public class MyObjectData {     private int objectId;     private List columnName;     private List columnValues;      public int getObjectId() {         return objectId;     }     public void setObjectId(int objectId) {         this.objectId = objectId;     }      public List getColumnName() {         return columnName;     }      public void setColumnName(List colName) {         this.columnName = colName;     }      public List getColumnValues() {         return columnValues;     }      public void setValues(List values) {         this.columnValues = values;     }  } 

Regarding the columnNames and columnValues, I feel like I should be doing something like this in the model instead:

private List<ColumnNames> columnNames;     private List<ColumnValues> columnValues;      public List<ColumnNames> getColumnNames() {         return columnNames;     }      public void setColumnNames(List<ColumnNames> columnNames) {         this.columnNames = columnNames;     }      public List<ColumnValues> getColumnValues() {         return columnValues;     }      public void setColumnValues(List<ColumnValues> columnValues) {         this.columnValues = columnValues;     } 

And then I’d have two separate classes for them like this:

package com.category;  import java.util.List;  public class ColumnName {      private String columnName;      public String getColumnName() {         return columnName;     }      public void setColumnName(String columnName) {         this.columnName = columnName;     }  }  package com.category;  import java.util.List;  public class ColumnValue {      private String columnValue;     private int columnValueId;      public String getColumnValue() {         return columnValue;     }      public void setColumnValue(String columnValue) {         this.columnValue = columnValue;     }      public String getColumnValueId() {         return columnValueId;     }      public void setColumnValueId(int columnValueId) {         this.columnValueId = columnValueId;     }  } 

I feel like I have all the right pieces but just not sure if this is a better approach than my initial attempt…which works. Just looking for input. Thanks in advance.

## Differences between enumeration-based and hierarchical token typing

When writing a lexer/parser, why/when would an advised developer chose to define the tokens’ types through an enumeration field/type hierarchy?

The closest question I’ve found here so far was Lexing: One token per operator, or one universal operator token? by Jeroen Bollen, but it seems to be more about the ideal deepth of the token type hierarchy.

As for my personal experience I’ve used Newtonsoft.Json‘s reader, which uses an enumeration, and I’ve read about C#’s Expression types, which seem to use a hierarchy, but also seem to be more than just tokens.

## Hierarchical Bayes Model

I am given a zip-inflated Poisson (ZIP) model, where random data $$X_1, .., X_n$$ are of the form $$X_i=R_iY_i$$, where the $$Y_i$$‘s have Poisson distribution ($$\lambda$$) and the $$R_i$$‘s have Bernoulli distribution ($$p$$), and all independent from each other. If given an outcome $$x = (x_1, .., x_n)$$, the objective is to estimate both $$\lambda$$ and $$p$$.

We can use a hierarchical Bayes model:

$$p$$ ~ Uniform(0,1) (prior for $$p$$),
$$(\lambda|p)$$ ~ Gamma(a,b) (prior for $$\lambda$$),
$$(r_i|p, \lambda )$$ ~ Bernoulli($$p$$) independently (from the model above),
$$(x_i|r, \lambda, p )$$ ~ Poisson($$\lambda r_i$$) independently (from the model above)

Since $$a$$ and $$b$$ are known parameters, and $$r = (r_1,…,r_n)$$, it follows that

$$f(x,r, \lambda, p) = \frac{b^\alpha \lambda^{\alpha-1} e^{-b \lambda}}{\Gamma(\alpha)} \prod_{i=1}^n\frac{e^{-\lambda r_i} (\lambda r_i)^{x_i}}{x_i!} p^{r_i}(1-p)^{1-r_i}$$

My question is to obtain the following:

1) $$\lambda|p,r,x\sim Gamma(a+ \sum_{i}x_i, b+ \sum_{i}r_i)$$
2) $$p|\lambda,r,x\sim Beta(1+ \sum_{i}r_i, n+1 – \sum_{i}r_i)$$
3) $$r_i|\lambda,p,x \sim Bernoulli(\frac{pe^{- \lambda}}{pe^{- \lambda}+(1-p)I{\{x_i=0}\}})$$

for 1) and 2), I am able to deduce them by integrating and removing the other variables. However, for 3), I was not able to do so and eventually obtained the following expression:

$$e^{\lambda \sum r_i} r_i^{\sum x_i} p^{\sum r_i} (1-p)^{n-\sum r_i}$$

Can anyone show me if what I did it correct and perhaps how to obtain the required expression?

Thank you.

## Hierarchical Deterministic (HD) Importing Funds

I’m creating derived addresses from a HD private key.

I have all data saved, such as the; seed, HD private key and derived addresses with their private keys, plus wif formats.

I’m receiving funds in each address, but need a way to import all the funds as efficiently as possible into a SPV wallet. At the moment I import each address wif to recieve its corresponding balance.

Is there a neat way to pull in all funds that derive from a “master key”. Or, have I misunderstood deterministic benefits – am I trying achieve a non existent feature?

TLDR; what’s the best way to import funds from multiple addresses?

## HSM for Hierarchical Deterministic Wallet

I’d like to use a small HSM to manage an HD Bitcoin wallet (BIP32). The HSM does have to correct ECDSA curve, secp256k1, can generate keypair, and sign.

My challenge comes from the HD part. In order to create hardened child keys, I need a SHA512 of the parent key and chaincode. The HSM doesn’t expose the parent key (that’s a “good thing”), and also doesn’t have any concept of a chaincode.

The larger vendors sell expensive HSM units that do have this kind of functionality, so there must be a way.

Specific questions: 1) How can I use an HSM, with private EC key to generate child keys following BIPS32?

2) How can I store part of the HD chain (seed, parent, child, etc.) in the HSM, and only expose part of it?

3) Any open source code examples for this?

THank You!

## .NET Custom hierarchical expression to treeview data structure

I’m not good at English. It’s gonna be hard to read. I apologize in advance.

I need expression parser for draw diagram(fault tree). In order to do that I have to create data structure from custom expression

( (123-A1) AND (123-A2) AND (123-A3) OR (123-A4 AND (123-A5 OR 123-A6)) ) 

The above example was written roughly as I thought.

1. In some cases, parentheses are used for each variable for readability.
2. Read in order within the same parentheses.
3. Read in order if there are no parentheses.
4. Parentheses around the expression can be attached without meaning.
5. Operators use only AND, OR parentheses use only (, ).
6. I don’t know which is the best way string to data structure.
7. The depth and order of parentheses and.. anything are all important because eventually I need to draw Diagram.
           _________OR___________           |                      |           |                 ____AND____           |                |           |            ______AND______         |       ___OR___    |       |       |        |      |        | 123-A1  123-A2  123-A3  123-A4  123-A5  123-A6 

Expression to Token

public class Token {     public TokenType Type;  // Operator, Parenthesis, Variable      public string Label;     public int Depth;     public int Group;      public Token(string label)     {         Label = label.Trim();          if (ExpressionParser.SupportedOperatorHashSet.Contains(label.ToUpper()))         {             Type = TokenType.Operator;         }         else if (ExpressionParser.SupportedParenthesesHashSet.Contains(label))         {             Type = TokenType.Parenthesis;         }         else         {             Type = TokenType.Variable;         }     } }  public enum TokenType {     Variable,     Operator,     Parenthesis }  public static class ExpressionParser {     private static Regex TokenRegex = new Regex(@"[]|[\d\w-]+");      internal static readonly HashSet<string> SupportedOperatorHashSet = new HashSet<string>() { AndGate, OrGate };     internal static readonly HashSet<string> SupportedParenthesesHashSet = new HashSet<string>() { OpenParenthesis, CloseParenthesis };     private static readonly List<Token> TokenList = new List<Token>();      internal const string AndGate = "AND";     internal const string OrGate = "OR";     internal const string OpenParenthesis = "(";     internal const string CloseParenthesis = ")";      public static List<Token> Parse(string expression)     {         try         {             // Get '(' ')' '123-A1' 'AND' 'OR'             MatchCollection matches = TokenRegex.Matches(expression); // @"[]|[\d\w-]+"             int depth = 0;              foreach (Match match in matches)             {                 Token token = new Token(match.Value);                 TokenList.Add(token);                  // Increase depth when token is open parenthesis                  if (token.Type == TokenType.Parenthesis && token.Label == OpenParenthesis)                 {                     depth += 1;                 }                  token.Depth = depth;                  // Set group                 if (TokenList.Count > 1)                 {                     Token prevToken = TokenList[TokenList.Count - 2];                     if (prevToken.Depth == token.Depth)                     {                         token.Group = prevToken.Group;                     }                     else                     {                         token.Group = prevToken.Group + 1;                     }                 }                  // Decrease depth after token is close parenthesis                  if (token.Type == TokenType.Parenthesis && token.Label == CloseParenthesis)                 {                     depth -= 1;                 }             }              // Remove parenthesis  [ex. (123-ab)]             for (int i = 0; i < TokenList.Count; i++)             {                 if (i + 2 < TokenList.Count &&                     TokenList[i].Type == TokenType.Parenthesis && TokenList[i].Label == OpenParenthesis &&                     TokenList[i + 2].Type == TokenType.Parenthesis && TokenList[i].Label == CloseParenthesis)                 {                     TokenList.RemoveAt(i + 2);                     TokenList.RemoveAt(i);                 }             }              return new List<Token>(TokenList);         }         finally         {             TokenList.Clear();         }     } } 

Run

ExpressionParser.Parse("( (123-A1) AND (123-A2) AND (123-A3) OR (123-A4 AND (123-A5 OR 123-A6)) )"); 

Result

OR  ├ AND  │  ├ 123-A1  │  ├ 123-A2  │  └ 123-A3  └ AND     ├ 123-A4     └ OR       ├ 123-A5       └ 123-A6