Finding maximal elements of a poset's subset

半腔热情 提交于 2020-02-03 08:52:31

问题


The problem is the following: Given a poset's subset S find the maximal elements of S.

For example consider the hass diagram of the poset in http://ndp.jct.ac.il/tutorials/Discrete/node34.html. Given a subset of it ex: {12, 2, 8} the maximal elements are 12 and 8.

I do not know if I describe precisly the problem. I think the problem might involves some sorting or computation of transitive closure but I am a little confused.

Could you give me some approach for a fast algorithm? I would like to keep it in O(n^2)

Thanks.

A little clarification. My application is using RDF graphs. Two nodes are comparable if there exists a specific edge that represent the < relation. Two nodes might be comparable if there is such an explicit relation or an implicit transitive one.

So assume that the hass diagram is exactly my RDF graph. If I start from 2 doing a depth-first search how do I know that the 8 and 12 are not comparable? They might not be explicitly but they might be implicitly.


回答1:


You can do this in linear time if you know a minimal subset of the ordering relation: regard it as a DAG, then do a depth-first traversal to find all vertices that have no successor.



来源:https://stackoverflow.com/questions/10140610/finding-maximal-elements-of-a-posets-subset

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!