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

Expose CheckCycle API #25

Open
Niels-Be opened this issue Jul 17, 2018 · 0 comments
Open

Expose CheckCycle API #25

Niels-Be opened this issue Jul 17, 2018 · 0 comments

Comments

@Niels-Be
Copy link

Hello,

In my use case I construct a graph to validate a user input. When the input changes I modify the graph accordingly. One of the validations is to check for cycles in the graph.

My current solutions is:

function checkCycle() {
    this.graph.circular = false;
    let res = null;
    try {
        this.graph.overallOrder();
    } catch(e) {
        res = e.message;
    }
    this.graph.circular = true;
    return res;
}

But I this is bad in multiple ways.

  1. First of all it modifies the internal circular property temporary. (not exposed to Typescript)
  2. It does unnecessary work, since the result of overallOrder() is not used.
  3. Relying on exceptions is not clean code.
  4. This might suppress other errors.

In my opinion checking for cycles is a general use case and it would be nice if the library can expose it as a function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants