Skip to content

Topological sort may not return a node in a cycle when it fails #264

Description

@flavioakira

A reproducible example:

Graph(1~>2, 2~>1, 2~>3, 3~>4, 4~>5, 5~>6, 6~>7, 7~>8, 8~>9, 9~>10).topologicalSort
// res: graph.CycleNodeOrTopologicalOrder = Left(9)

Graph(1~>2, 2~>1, 2~>3, 3~>4, 4~>5, 5~>6, 6~>7, 7~>8, 8~>9, 9~>10).topologicalSortByComponent.toList
// res: List[graph.CycleNodeOrTopologicalOrder] = List(Left(9))

val graph = Graph(1~>2, 2~>1, 2~>3, 3~>4, 4~>5, 5~>6, 6~>7, 7~>8, 8~>9, 9~>10)
graph.topologicalSort match {
  case Left(nodeInCycle) => graph.findCycleContaining(nodeInCycle)
}
// res: Option[graph.Cycle] = None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions