Ticket #5911: trac_5911-reviewer.patch

File trac_5911-reviewer.patch, 10.0 KB (added by mvngu, 11 years ago)

reviewer patch

  • sage/graphs/graph.py

    # HG changeset patch
    # User Minh Van Nguyen <nguyenminh2@gmail.com>
    # Date 1256741914 25200
    # Node ID 530201d00485590c43ce9777652f04646aed4e38
    # Parent  d567b32f0c6318164f67ae3c0b135148cda13174
    trac 5911: reviewer patch
    
    diff -r d567b32f0c63 -r 530201d00485 sage/graphs/graph.py
    a b  
    88618861    r"""
    88628862    Undirected graph.
    88638863
    8864     A Graph is a set of vertices connected by edges
     8864    A graph is a set of vertices connected by edges
    88658865    (cf. http://en.wikipedia.org/wiki/Graph_(mathematics) ).
    88668866
    8867     One can very easily create a graph in sage by typing::
    8868    
    8869         sage: g=Graph()
    8870 
    8871     By typing the name of the Graph, one can get some basic information
     8867    One can very easily create a graph in Sage by typing::
     8868   
     8869        sage: g = Graph()
     8870
     8871    By typing the name of the graph, one can get some basic information
    88728872    about it::
    88738873
    88748874        sage: g
    88758875        Graph on 0 vertices
    88768876
    8877     This graph is not very interesting as it is by default the empty graph. But
    8878     Sage contains a large collection of pre-defined graph classes that can be listed
    8879     this way:
    8880    
    8881         * Type in Sage : graphs.
    8882           ( do not press "Enter", and do not forget the final "." )
    8883         * Hit "tab".
     8877    This graph is not very interesting as it is by default the empty graph.
     8878    But Sage contains a large collection of pre-defined graph classes that
     8879    can be listed this way:
     8880   
     8881    * Within a Sage session, type ``graphs.``
     8882      (Do not press "Enter", and do not forget the final period ".")
     8883    * Hit "tab".
    88848884   
    88858885    You will see a list of methods which will construct named graphs. For
    88868886    example::
    88878887
    8888         sage: g=graphs.PetersenGraph()
     8888        sage: g = graphs.PetersenGraph()
    88898889        sage: g.plot()
    88908890
    88918891    or::
    88928892
    8893         sage: g=graphs.ChvatalGraph()
     8893        sage: g = graphs.ChvatalGraph()
    88948894        sage: g.plot()
    88958895
    88968896    In order to obtain more information about these graph constructors, access
    8897     the documentation as follows::
    8898 
    8899         sage: graphs.RandomGNP?
    8900 
    8901     Once you have defined the graph you want, you can begin to work on it by using the
    8902     almost 200 functions on graphs in the Sage library !
    8903     If your graph is named ``g``, you can list these functions as previously this way
    8904    
    8905         * Type in Sage : ``g.``
    8906           ( do not press "Enter", and do not forget the final "." )
    8907         * Hit "tab".
    8908 
    8909     As usual, you can get some information about what these functions do by typing
    8910     (e.g. if you want to know about the ``diameter()`` method)::
    8911 
    8912         sage: g.diameter?
    8913 
    8914     If you have defined a graph ``g`` having several connected components ( i.e.
    8915     ``g.is_connected()`` returns False ), you can print each one of its
     8897    the documentation using the command ``graphs.RandomGNP?``.
     8898
     8899    Once you have defined the graph you want, you can begin to work on it
     8900    by using the almost 200 functions on graphs in the Sage library!
     8901    If your graph is named ``g``, you can list these functions as previously
     8902    this way
     8903   
     8904    * Within a Sage session, type ``g.``
     8905      (Do not press "Enter", and do not forget the final period "." )
     8906    * Hit "tab".
     8907
     8908    As usual, you can get some information about what these functions do by
     8909    typing (e.g. if you want to know about the ``diameter()`` method)
     8910    ``g.diameter?``.
     8911
     8912    If you have defined a graph ``g`` having several connected components
     8913    (i.e. ``g.is_connected()`` returns False), you can print each one of its
    89168914    connected components with only two lines::
    89178915   
    89188916        sage: for component in g.connected_components():
     
    89218919
    89228920    INPUT:
    89238921   
    8924     -  ``data`` -  can be any of the following:
    8925 
    8926        #.  A dictionary of dictionaries
    8927 
    8928        #.  A dictionary of lists
    8929 
    8930        #.  A numpy matrix or ndarray
    8931 
    8932        #.  A Sage adjacency matrix or incidence matrix
    8933 
    8934        #.  A pygraphviz agraph
    8935 
    8936        #.  A SciPy sparse matrix
    8937 
    8938        #.  A NetworkX digraph
    8939 
    8940     -  ``pos`` - a positioning dictionary: for example, the
     8922    -  ``data`` -- can be any of the following:
     8923
     8924      #.  A dictionary of dictionaries
     8925
     8926      #.  A dictionary of lists
     8927
     8928      #.  A NumPy matrix or ndarray
     8929
     8930      #.  A Sage adjacency matrix or incidence matrix
     8931
     8932      #.  A pygraphviz agraph
     8933
     8934      #.  A SciPy sparse matrix
     8935
     8936      #.  A NetworkX digraph
     8937
     8938    -  ``pos`` -  a positioning dictionary: for example, the
    89418939       spring layout from NetworkX for the 5-cycle is::
    89428940
    89438941         {0: [-0.91679746, 0.88169588],
     
    89478945          4: [-1.125     ,-0.50118505]}
    89488946   
    89498947    -  ``name`` - (must be an explicitly named parameter,
    8950        i.e., name="complete") gives the graph a name
     8948       i.e., ``name="complete")`` gives the graph a name
    89518949   
    89528950    -  ``loops`` - boolean, whether to allow loops (ignored
    8953        if data is an instance of the Graph class)
     8951       if data is an instance of the ``Graph`` class)
    89548952   
    89558953    -  ``multiedges`` - boolean, whether to allow multiple
    8956        edges (ignored if data is an instance of the Graph class)
     8954       edges (ignored if data is an instance of the ``Graph`` class)
    89578955   
    89588956    -  ``weighted`` - whether graph thinks of itself as
    8959        weighted or not. See self.weighted()
     8957       weighted or not. See ``self.weighted()``
    89608958   
    89618959    -  ``format`` - if None, Graph tries to guess- can be
    89628960       several values, including:
     
    90029000       only the integers 0, ..., n-1, where n is the number of vertices.
    90039001   
    90049002   
    9005     EXAMPLES: We illustrate the first six input formats (the other two
     9003    EXAMPLES:
     9004
     9005    We illustrate the first six input formats (the other two
    90069006    involve packages that are currently not standard in Sage):
    90079007   
    90089008    #. A dictionary of dictionaries::
     
    90699069          [1 0 1 1 0 1]
    90709070          [0 1 1 1 1 0]
    90719071   
    9072     #. A numpy matrix or ndarray::
     9072    #. A NumPy matrix or ndarray::
    90739073   
    90749074        sage: import numpy
    90759075        sage: A = numpy.array([[0,1,1],[1,0,1],[1,1,0]])
     
    1077510775    """
    1077610776    Directed graph.
    1077710777
    10778     A DiGraph is a set of vertices connected by oriented edges
    10779     (cf. http://en.wikipedia.org/wiki/Digraph_%28mathematics%29 ).
    10780 
    10781     One can very easily create a directed graph in sage by typing::
    10782    
    10783         sage: g=DiGraph()
    10784 
    10785     By typing the name of the DiGraph, one can get some basic information
     10778    A digraph or directed graph is a set of vertices connected by oriented
     10779    edges (cf. http://en.wikipedia.org/wiki/Digraph_%28mathematics%29 ).
     10780
     10781    One can very easily create a directed graph in Sage by typing::
     10782   
     10783        sage: g = DiGraph()
     10784
     10785    By typing the name of the digraph, one can get some basic information
    1078610786    about it::
    1078710787
    1078810788        sage: g
    1078910789        Digraph on 0 vertices
    1079010790
    10791     This digraph is not very interesting as it is by default the empty graph. But
    10792     Sage contains several pre-defined digraph classes that can be listed
    10793     this way:
    10794    
    10795         * Type in Sage : digraphs.
    10796           ( do not press "Enter", and do not forget the final "." )
    10797         * Hit "tab".
     10791    This digraph is not very interesting as it is by default the empty
     10792    graph. But Sage contains several pre-defined digraph classes that can
     10793    be listed this way:
     10794   
     10795    * Within a Sage sessions, type ``digraphs.``
     10796      (Do not press "Enter", and do not forget the final period "." )
     10797    * Hit "tab".
    1079810798   
    1079910799    You will see a list of methods which will construct named digraphs. For
    1080010800    example::
    1080110801
    10802         sage: g=digraphs.ButterflyGraph(3)
     10802        sage: g = digraphs.ButterflyGraph(3)
    1080310803        sage: g.plot()
    1080410804       
    10805     You can also use the collection of pre-defined graphs, then create a DiGraph
    10806     from them. ::
    10807 
    10808         sage: g=DiGraph(graphs.PetersenGraph())
     10805    You can also use the collection of pre-defined graphs, then create a
     10806    digraph from them. ::
     10807
     10808        sage: g = DiGraph(graphs.PetersenGraph())
    1080910809        sage: g.plot()
    1081010810
    10811     Calling ``Digraph`` on a graph returns the original graph in which every edge
    10812     is replaced by two different edges going toward opposite directions.
    10813 
    10814     In order to obtain more information about these degraph constructors, access
    10815     the documentation as follows::
    10816 
    10817         sage: digraphs.RandomDirectedGNP?
    10818 
    10819     Once you have defined the digraph you want, you can begin to work on it by using the
    10820     almost 200 functions on graphs and digraphs in the Sage library !
    10821     If your digraph is named ``g``, you can list these functions as previously this way
    10822    
    10823         * Type in Sage : ``g.``
    10824           ( do not press "Enter", and do not forget the final "." )
    10825         * Hit "tab".
    10826 
    10827     As usual, you can get some information about what these functions do by typing
    10828     (e.g. if you want to know about the ``diameter()`` method)::
    10829 
    10830         sage: g.diameter?
    10831 
    10832     If you have defined a digraph ``g`` having several connected components ( i.e.
    10833     ``g.is_connected()`` returns False ), you can print each one of its
     10811    Calling ``Digraph`` on a graph returns the original graph in which every
     10812    edge is replaced by two different edges going toward opposite directions.
     10813
     10814    In order to obtain more information about these digraph constructors,
     10815    access the documentation by typing ``digraphs.RandomDirectedGNP?``.
     10816
     10817    Once you have defined the digraph you want, you can begin to work on it
     10818    by using the almost 200 functions on graphs and digraphs in the Sage
     10819    library! If your digraph is named ``g``, you can list these functions as
     10820    previously this way
     10821   
     10822    * Within a Sage session, type ``g.``
     10823      (Do not press "Enter", and do not forget the final period "." )
     10824    * Hit "tab".
     10825
     10826    As usual, you can get some information about what these functions do by
     10827    typing (e.g. if you want to know about the ``diameter()`` method)
     10828    ``g.diameter?``.
     10829
     10830    If you have defined a digraph ``g`` having several connected components
     10831    ( i.e. ``g.is_connected()`` returns False ), you can print each one of its
    1083410832    connected components with only two lines::
    1083510833   
    1083610834        sage: for component in g.connected_components():