# HG changeset patch
# User Chris Berg <chrisjamesberg@gmail.com>
# Date 1371045727 7200
# Node ID 58e213444d1d059c322ca7fe3c2391ed482a491f
# Parent ec6a3e8365f9c930df8da62874d84f198ad59ca4
#14732 Poset to Graph method
diff git a/sage/combinat/posets/posets.py b/sage/combinat/posets/posets.py
a

b


128  128  from sage.graphs.digraph import DiGraph 
129  129  from sage.combinat.posets.hasse_diagram import HasseDiagram 
130  130  from sage.combinat.posets.elements import PosetElement 
 131  from sage.combinat.combinatorial_map import combinatorial_map 
131  132  
132  133  def Poset(data=None, element_labels=None, cover_relations=False, linear_extension=False, category = None, facade = None, key = None): 
133  134  r""" 
… 
… 

1425  1426  self.plot(label_elements=label_elements, element_labels=element_labels, 
1426  1427  vertex_size=vertex_size, vertex_colors=vertex_colors, layout=layout).show(**kwds) 
1427  1428  
 1429  @combinatorial_map(name="to graph") 
 1430  def to_graph(self): 
 1431  """ 
 1432  Return the graph of ``self`` corresponding to forgetting the 
 1433  poset structure. 
 1434  
 1435  EXAMPLES:: 
 1436  
 1437  sage: P = Poset({0:[1,2],1:[3],2:[3],3:[]}) 
 1438  sage: P.to_graph() 
 1439  Graph on 4 vertices 
 1440  sage: P = Poset() 
 1441  sage: P.to_graph() 
 1442  Graph on 0 vertices 
 1443  """ 
 1444  from sage.graphs.graph import Graph 
 1445  return Graph(self.hasse_diagram()) 
 1446  
1428  1447  def level_sets(self): 
1429  1448  """ 
1430  1449  Returns a list l such that l[i+1] is the set of minimal elements of 