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

CompressedSparseRow bug #169

Open
AwesomeLemon opened this issue May 26, 2017 · 1 comment
Open

CompressedSparseRow bug #169

AwesomeLemon opened this issue May 26, 2017 · 1 comment

Comments

@AwesomeLemon
Copy link

While looking through sources in file https://github.com/YaccConstructor/QuickGraph/blob/master/src/QuickGraph/CompressedSparseRowGraph.cs I've noticed that the method FromGraph seems likely not to work due to the fact that start variable isn't updated after initialization.

I've confirmed my suspicions: I've run Topological sort on adjacency graph (it turned out OK), then converted that graph to CSR and run on that - it throws QuickGraph.NonAcyclicGraphException

Sample code:

            // a simple adjacency graph representation
            int[][] graph = new int[5][];
            graph[0] = new int[] {  };
            graph[1] = new int[] { 2, 3 };
            graph[2] = new int[] { 3, 0 };
            graph[3] = new int[] { 0 };
            graph[4] = new int[] { 1 };

            // interoping with quickgraph
            var g = GraphExtensions.ToDelegateVertexAndEdgeListGraph(
                Enumerable.Range(0, graph.Length),
                v => Array.ConvertAll(graph[v], w => new SEquatableEdge<int>(v, w))
            );
            
            // it's ready to use!
            foreach (var v in g.TopologicalSort())
                Console.WriteLine(v);
            
            var csr = CompressedSparseRowGraph<int>.FromGraph(g);
            foreach (var vertex in csr.TopologicalSort())
            {
                Console.WriteLine(vertex);
            }

P.S. It turned out that there's no sense for me in using QuickGraph's CSR anyway, so I just want to report this.

@KeRNeLith
Copy link

I made a fix for this (there) and also unit tests in this fork of the library (with also a lot of others fixes and .NET Core compliance).

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

3 participants