Skip to content

topological-sort DAG exception #7

@andriiheonia

Description

@andriiheonia

What wrong with my code? I have an exception "The graph is not a DAG".

var topsort = require('../src/graphs/others/topological-sort').topologicalSort;
var graph = [[0, 1, 0, 0, 1],
             [0, 0, 0, 0, 0],
             [1, 1, 0, 1, 1],
             [0, 0, 0, 0, 0],
             [0, 0, 0, 0, 0]];
var vertices = topsort(graph);

But there is a graph I want to represent:
image001

and it looks directed and acyclic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions