Java partially ordered Collection

后端 未结 1 1128
终归单人心
终归单人心 2021-01-11 11:32

I am looking for a Java implementation of a data structure which holds a collection of elements for which a partial ordering is defined, and which allows on

相关标签:
1条回答
  • 2021-01-11 11:44

    Would a directed acyclic graph be sufficiently general for your needs? I know that this doesn't capture posets generally, but you mentioned wanting to exclude graph cycles.

    If so you might look at JGraphT: http://jgrapht.org/

    There's a graph iterator for topological sorts.

    Note that the directed graphs aren't java.util.Collections, but you can grab the vertices, which are a java.util.Set. If you need the data structure itself to be a Collection, you could probably wrap a JGraphT directed graph with a thin wrapper that is a Collection, treating the vertices as elements.

    The potential drawback here is that you have to create edges explicitly, which may or may not be acceptable for your application.

    0 讨论(0)
提交回复
热议问题