pgmpy / pgmpy_viz

A web based GUI for pgmpy
MIT License
13 stars 20 forks source link

Bug if adding node by default name #25

Closed ankurankan closed 10 years ago

ankurankan commented 10 years ago

If the user doesn't enter the name of the node, the node is created by the default name. Let's assume that the user inputs the name of the first node to be node10 which is the default name for 10th node, and then creates the 10th node with its default name. What will happen in this case? Also don't you think it would be better if we increase the default node name only when the earlier name has been used?

e55k4y commented 10 years ago

Firstly, there would not be any issue with our back-end processing of data as it involves use of only "id" of node and never the name for identifying them. So as far as the bug is concerned, it can cause conflict with pre-existing node name. As a solution, the button for saving the node name can be disabled if the name is conflicting.

For the second case, a global variable can be used to maintain the no. of default named nodes.

ankurankan commented 10 years ago

I think a better solution would be to increment the default name if the name is conflicting. I didn't mean to have a global variable. What I meant was that let's say the user puts a name for the first node then the second node's default name should be node0 not node1. What do you think?

e55k4y commented 10 years ago

The problem with that would be if the user does a mistake and gives conflicting names, the default name would be saved automatically. So, I was suggesting to use some validation such that only non-conflicting names are saved. Also, we would need the variable to generate the default name, which is currently being done using the no. of nodes in the graph.

e55k4y commented 10 years ago

How about this:

while(check(defName)){
defName = "node"+ n++; //n is a variable for available smallest default name
}

function check(defName){
//check whether name is conflicting
if(/*defName conflicting*/)
return true;
else
return false;
}
ankurankan commented 10 years ago

Then, I guess some validation that would show the user that there's a conflict in the name would be the best solution.

gargshashank5 commented 10 years ago

I also agree with having a validation for duplicate names. What if user himself uses the same name twice. @ankurankan I think incrementing the default name only in conflicting cases will be confusing. Having a node name node x where x has no connection with the node is confusing.

e55k4y commented 10 years ago

I agree with @gargshashank5 about the default name. I will add a validator which will disable the submit button if the name is conflicting and also disallow any name of format "nodex",x being any integer.

gargshashank5 commented 10 years ago

@e55k4y I don't think we should disallow any type of names. If user himself is giving nodeX kind of names then he may have some purpose. Related to name what we should do is:

e55k4y commented 10 years ago

All the said changes are done. Please close this issue.