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

interaction of topologicalSort with withSubgraph #104

rbodik opened this issue Apr 1, 2018 · 1 comment

interaction of topologicalSort with withSubgraph #104

rbodik opened this issue Apr 1, 2018 · 1 comment


Copy link

@rbodik rbodik commented Apr 1, 2018

Hello, topologicalSort seems to find a cycle in an acyclic directed graph when that graph is edge-filtered. Is this expected behavior? This cycle can't be found with findCycle.

import scalax.collection.mutable.Graph
import scalax.collection.edge.Implicits._
import scalax.collection.GraphPredef._

val g1 = Graph( 1 ~> 3,                         2 ~> 3)
val g2 = Graph((1 ~+> 3)("a"), (1 ~+> 2)("b"), (2 ~+> 3)("a"))

// The next two calls return a topo sort, as expected. 

// The next topologicalSort finds a cycle on node 3.  
// I would expect the filtered graph to have a topo sort exactly as in graph `g1` rooted in `g1.get(1)`.
g2.get(1).withSubgraph(edges = _.label == "a").topologicalSort() 

// The cycle on node 3 can't be found with findCycle
g2.get(1).withSubgraph(edges = _.label == "a").findCycle

// For an insider, the next three return values may shed some light into the unexpected behavior.
g2.get(1).withSubgraph(edges = _.label == "a")
Copy link

@peter-empen peter-empen commented Apr 3, 2018

Ras, thank you for reporting.

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

Successfully merging a pull request may close this issue.

None yet
2 participants