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". |
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 |
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 |
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 |
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". |
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 |