Ticket #14732: posets_to_graph.patch

File posets_to_graph.patch, 1.6 KB (added by chrisjamesberg, 6 years ago)
  • sage/combinat/posets/posets.py

    # 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  
    128128from sage.graphs.digraph import DiGraph
    129129from sage.combinat.posets.hasse_diagram import HasseDiagram
    130130from sage.combinat.posets.elements import PosetElement
     131from sage.combinat.combinatorial_map import combinatorial_map
    131132
    132133def Poset(data=None, element_labels=None, cover_relations=False, linear_extension=False, category = None, facade = None, key = None):
    133134    r"""
     
    14251426        self.plot(label_elements=label_elements, element_labels=element_labels,
    14261427            vertex_size=vertex_size, vertex_colors=vertex_colors, layout=layout).show(**kwds)
    14271428
     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
    14281447    def level_sets(self):
    14291448        """
    14301449        Returns a list l such that l[i+1] is the set of minimal elements of