Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDs are random. Makes it hard to compare saved graphs #154

Closed
pachacamac opened this issue Jul 13, 2021 · 3 comments
Closed

IDs are random. Makes it hard to compare saved graphs #154

pachacamac opened this issue Jul 13, 2021 · 3 comments
Assignees
Labels
core Issues regarding the core of BaklavaJS

Comments

@pachacamac
Copy link

export default function generateId() {
    return Date.now().toString() + (counter++).toString();
}

So currently the IDs for nodes, interfaces, connections are generated with the help of this function.

This is an issue because it makes it impossible to compare one saved version of a graph to another as they always differ.

Would it be possible to use some sort of hashing instead?

  • for nodes over position, name, interfaces, options etc
  • for connections over source- and destination interface
  • for interfaces over parent node, type, options?

Something like that?

@newcat
Copy link
Owner

newcat commented Jul 13, 2021

I don't think this is feasible, since the ids are also used in the editor internally and in Vue components as keys. So when calculating a hash based on the state of the node, it would change the hash whenever you move the node or change the value. Also it is certainly possible to have two different nodes at the same position and with the same state, which would result in the same id even though they are two different instances.

When loading a saved graph, the existing ids are loaded as well. So it should be possible to compare two versions of the same graph, because nodes and node interfaces will keep their id. Connections currently don't load their id, but this shouldn't really matter, since the from.id and to.id are loaded from the saved graph, so they can be compared as well.

If it would make life easier for you I can change it so that connections also load their id.

@newcat newcat added the core Issues regarding the core of BaklavaJS label Jul 13, 2021
@pachacamac
Copy link
Author

Thanks for clarifying! Now that you say it I think I only had an issue with the connections indeed. Then I checked how the IDs are generated and saw that they all use the same function. But yes I think this would make it more consistent if connections follow the same logic as nodes and interfaces.

@newcat newcat self-assigned this Jul 14, 2021
@newcat
Copy link
Owner

newcat commented Jul 25, 2021

Implemented in v1.9.1

@newcat newcat closed this as completed Jul 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues regarding the core of BaklavaJS
Projects
None yet
Development

No branches or pull requests

2 participants