Ticket #5911: doc_graph.patch

File doc_graph.patch, 5.6 KB (added by ncohen, 11 years ago)
  • sage/graphs/graph.py

    # HG changeset patch
    # User Nathann Cohen <nathann.cohen@gmail.com>
    # Date 1250521652 -7200
    # Node ID beaee80c307efdd7d4e87caf5d6918650c8a2508
    # Parent  684eea91ff224e5bc6259ca19f1576c4c082b9d3
    Some movement in the docstring from Graph?
    
    diff -r 684eea91ff22 -r beaee80c307e sage/graphs/graph.py
    a b  
    87898789class Graph(GenericGraph):
    87908790    r"""
    87918791    Undirected graph.
    8792    
     8792
     8793    A Graph is a set of vertices connected by edges
     8794    (cf. http://en.wikipedia.org/wiki/Graph_(mathematics) )
     8795
     8796    One can very easily create a graph in sage by typing ::
     8797   
     8798        sage: g=Graph()
     8799
     8800    By typing the name of the Graph, one can get some basic informations
     8801    about it::
     8802
     8803        sage: g
     8804        Graph on 0 vertices
     8805
     8806    This graph is not very interesting as it is by default the empty graph.. But
     8807    Sage contains a large collection of pre-defined graph classes that can be listed
     8808    this way :
     8809   
     8810        * type in Sage : graphs.
     8811          ( do not press "Enter", and do not forget the final "." )
     8812        * hit "tabulation" two times in a row
     8813   
     8814    You will see the list of methods defined in the class "graphs", all of which
     8815    generate graphs you can play with !
     8816
     8817    If you want to see what they look like, begin this way ::
     8818   
     8819        sage: g=graphs.PetersenGraph()
     8820        sage: g.plot()
     8821
     8822    or::
     8823
     8824        sage: g=graphs.ChvatalGraph()
     8825        sage: g.plot()
     8826
     8827    If you are curious about what these graphs are, for example if you wonder what ``RandomGNP``
     8828    actually is, you but have to type::
     8829
     8830        sage: graphs.RandomGNP?
     8831
     8832    Once you have defined the graph you want, you can begin to work on it by using the
     8833    almost 200 functions on graphs in the Sage library !
     8834    If your graph is named ``g``, you can list these functions as previously this way
     8835   
     8836        * type in Sage : ``g.``
     8837          ( do not press "Enter", and do not forget the final "." )
     8838        * hit "tabulation" two times in a row   
     8839
     8840    As usual, you can get some information about what these functions do by typing
     8841    ( if you want to know about the ``diameter()`` method )::
     8842
     8843        sage: g.diameter?
     8844
     8845    If you have defined a graph ``g`` having several connected components ( = which is not
     8846    connected... Type ``g.is_connected()`` to know if your graph is connected ), you can
     8847    print each one of its connected components with only two lines :
     8848   
     8849    ( if you do not have such a graph G, here is one for free :  ``g=graphs.RandomGNP(30,.05)``    )::
     8850   
     8851        sage: for component in g.connected_components():
     8852        ...      g.subgraph(component).plot()
     8853   
     8854
    87938855    INPUT:
    87948856   
    87958857    -  ``data`` -  can be any of the following:
    87968858
     8859       #.  A dictionary of dictionaries
     8860
     8861       #.  A dictionary of lists
     8862
     8863       #.  A numpy matrix or ndarray
     8864
     8865       #.  A Sage adjacency matrix or incidence matrix
     8866
     8867       #.  A pygraphviz agraph
     8868
     8869       #.  A SciPy sparse matrix
     8870
    87978871       #.  A NetworkX digraph
    87988872
    8799        #.  A dictionary of dictionaries
    8800 
    8801        #.  A dictionary of lists
    8802 
    8803        #.  A NumPy matrix or ndarray
    8804 
    8805        #.  A Sage adjacency matrix or incidence matrix
    8806 
    8807        #.  A pygraphviz agraph
    8808 
    8809        #.  A SciPy sparse matrix
    8810 
    88118873    -  ``pos`` - a positioning dictionary: for example, the
    88128874       spring layout from NetworkX for the 5-cycle is::
    88138875
     
    88768938    EXAMPLES: We illustrate the first six input formats (the other two
    88778939    involve packages that are currently not standard in Sage):
    88788940   
    8879     #. A NetworkX XGraph::
    8880    
    8881           sage: import networkx
    8882           sage: g = networkx.XGraph({0:[1,2,3], 2:[4]})
    8883           sage: Graph(g)
    8884           Graph on 5 vertices
    8885    
    8886     #. A NetworkX graph::
    8887    
    8888            sage: import networkx
    8889            sage: g = networkx.Graph({0:[1,2,3], 2:[4]})
    8890            sage: DiGraph(g)
    8891            Digraph on 5 vertices
    8892    
    8893     Note that in all cases, we copy the NetworkX structure.
    8894    
    8895        ::
    8896    
    8897           sage: import networkx
    8898           sage: g = networkx.Graph({0:[1,2,3], 2:[4]})
    8899           sage: G = Graph(g, implementation='networkx')
    8900           sage: H = Graph(g, implementation='networkx')
    8901           sage: G._backend._nxg is H._backend._nxg
    8902           False
    8903    
    8904 
    8905 
    89068941    #. A dictionary of dictionaries::
    89078942   
    89088943        sage: g = Graph({0:{1:'x',2:'z',3:'a'}, 2:{5:'out'}}); g
     
    89679002          [1 0 1 1 0 1]
    89689003          [0 1 1 1 1 0]
    89699004   
    8970     #. A NumPy matrix or ndarray::
     9005    #. A numpy matrix or ndarray::
    89719006   
    89729007        sage: import numpy
    89739008        sage: A = numpy.array([[0,1,1],[1,0,1],[1,1,0]])
     
    90899124            ValueError: Non-symmetric or non-square matrix assumed to be an incidence matrix: Each column represents an edge: -1 goes to 1.
    90909125
    90919126
     9127    #. A NetworkX XGraph::
     9128   
     9129          sage: import networkx
     9130          sage: g = networkx.XGraph({0:[1,2,3], 2:[4]})
     9131          sage: Graph(g)
     9132          Graph on 5 vertices
     9133   
     9134    #. A NetworkX graph::
     9135   
     9136           sage: import networkx
     9137           sage: g = networkx.Graph({0:[1,2,3], 2:[4]})
     9138           sage: DiGraph(g)
     9139           Digraph on 5 vertices
     9140   
     9141    Note that in all cases, we copy the NetworkX structure.
     9142   
     9143       ::
     9144   
     9145          sage: import networkx
     9146          sage: g = networkx.Graph({0:[1,2,3], 2:[4]})
     9147          sage: G = Graph(g, implementation='networkx')
     9148          sage: H = Graph(g, implementation='networkx')
     9149          sage: G._backend._nxg is H._backend._nxg
     9150          False
    90929151    """
    90939152    _directed = False
    90949153