Strange

27 views
Skip to first unread message

Henri Girard

unread,
Apr 7, 2018, 8:52:22 AM4/7/18
to sage-s...@googlegroups.com

I made this graph (meaning a fano's plane) but I have the zero outside the graph ?

I don't understand why ? someone could explain ?

My adjacency_matrix is 8 but shouldn't be 7 ?

g=Graph(7)
edges = [(1,2), (1,3), (1,4),
    (2,3), (2,4), (2,5), (2, 6),
    (3,4), (3,5), (3,6), (3,7),
    (4,6), (4,7), (5,6), (6,7)]
g.add_edge(1,2),g.add_edge(1,3),g.add_edge(1,4),g.add_edge(2,3),
g.add_edge(2,4),g.add_edge(2,5),g.add_edge(2,6),g.add_edge(3,4),
g.add_edge(3,5),g.add_edge(3,6),g.add_edge(3,7),g.add_edge(4,6),
g.add_edge(4,7),g.add_edge(5,6),g.add_edge(6,7)
g.show()
g.adjacency_matrix(),g.incidence_matrix()

Best

Henri

David Joyner

unread,
Apr 7, 2018, 8:58:50 AM4/7/18
to SAGE support
On Sat, Apr 7, 2018 at 8:52 AM, Henri Girard <henri....@gmail.com> wrote:

I made this graph (meaning a fano's plane) but I have the zero outside the graph ?

I don't understand why ? someone could explain ?


I don't know but

sage: edges = [(1,2), (1,3), (1,4),
....:     (2,3), (2,4), (2,5), (2, 6),
....:     (3,4), (3,5), (3,6), (3,7),
....:     (4,6), (4,7), (5,6), (6,7)]
sage: Gamma = Graph(edges)
sage: Gamma.show()

gives the same graph but without the 0 vertex.  

My adjacency_matrix is 8 but shouldn't be 7 ?

g=Graph(7)
edges = [(1,2), (1,3), (1,4),
    (2,3), (2,4), (2,5), (2, 6),
    (3,4), (3,5), (3,6), (3,7),
    (4,6), (4,7), (5,6), (6,7)]
g.add_edge(1,2),g.add_edge(1,3),g.add_edge(1,4),g.add_edge(2,3),
g.add_edge(2,4),g.add_edge(2,5),g.add_edge(2,6),g.add_edge(3,4),
g.add_edge(3,5),g.add_edge(3,6),g.add_edge(3,7),g.add_edge(4,6),
g.add_edge(4,7),g.add_edge(5,6),g.add_edge(6,7)
g.show()
g.adjacency_matrix(),g.incidence_matrix()

Best

Henri

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscribe@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Jan Groenewald

unread,
Apr 7, 2018, 9:10:27 AM4/7/18
to sage-support
Hi



Graph? shows

      2. "Graph(5)" -- return an edgeless graph on the 5 vertices
         0,...,4.

      3. "Graph([list_of_vertices,list_of_edges])" -- returns a
         graph with given vertices/edges.

         To bypass auto-detection, prefer the more explicit
         "Graph([V,E],format='vertices_and_edges')".

      4. "Graph(list_of_edges)" -- return a graph with a given list
         of edges (see documentation of "add_edges()").

         To bypass auto-detection, prefer the more explicit "Graph(L,
         format='list_of_edges')".

      5. "Graph({1:[2,3,4],3:[4]})" -- return a graph by
         associating to each vertex the list of its neighbors.

         To bypass auto-detection, prefer the more explicit "Graph(D,
         format='dict_of_lists')".

so it seems correct, and there are alternatives if you prefer 1..8 instead of 0..7.

Regards,
Jan




--
  .~.
  /V\     Jan Groenewald
 /( )\    www.aims.ac.za
 ^^-^^ 

Henri Girard

unread,
Apr 7, 2018, 9:16:08 AM4/7/18
to sage-s...@googlegroups.com

thanks, I tried david suggestion and it's correct now :

edges = [(1,2), (1,3), (1,4),
    (2,3), (2,4), (2,5), (2, 6),
    (3,4), (3,5), (3,6), (3,7),
    (4,6), (4,7), (5,6), (6,7)]

Gamma = Graph(edges)
Gamma.show()


Meanwhile I made it too with networkx to compare :

import networkx as nx                                                     
import matplotlib.pyplot as plt                                           
G = nx.Graph()                                                            

edges = [(1,2), (1,3), (1,4),
    (2,3), (2,4), (2,5), (2, 6),
    (3,4), (3,5), (3,6), (3,7),
    (4,6), (4,7), (5,6), (6,7)]

G.add_edges_from(edges)                                                   
nx.draw_networkx(G)                                                       
limits = plt.axis('off')                                                  
plt.show(G) 

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.

Nikos Apostolakis

unread,
Apr 7, 2018, 11:32:14 AM4/7/18
to sage-s...@googlegroups.com
Graph(7) creates a graph with vertices {0 ..., 6}

HTH,
Nikos

Sent from my iPhone 

On Apr 7, 2018, at 9:16 AM, Henri Girard <henri....@gmail.com> wrote:

thanks, I tried david suggestion and it's correct now :

edges = [(1,2), (1,3), (1,4),
    (2,3), (2,4), (2,5), (2, 6),
    (3,4), (3,5), (3,6), (3,7),
    (4,6), (4,7), (5,6), (6,7)]
Gamma = Graph(edges)
Gamma.show()

<lniocoeghomimbcp.png>


Meanwhile I made it too with networkx to compare :

import networkx as nx                                                     
import matplotlib.pyplot as plt                                           
G = nx.Graph()                                                            
edges = [(1,2), (1,3), (1,4),
    (2,3), (2,4), (2,5), (2, 6),
    (3,4), (3,5), (3,6), (3,7),
    (4,6), (4,7), (5,6), (6,7)]
G.add_edges_from(edges)                                                   
nx.draw_networkx(G)                                                       
limits = plt.axis('off')                                                  
plt.show(G) 

<aelkcedhefjgaigh.png>



Le 07/04/2018 à 15:09, Jan Groenewald a écrit :
Hi

On 7 April 2018 at 14:52, Henri Girard <henri....@gmail.com> wrote:

I made this graph (meaning a fano's plane) but I have the zero outside the graph ?

I don't understand why ? someone could explain ?

My adjacency_matrix is 8 but shouldn't be 7 ?

g=Graph(7)
edges = [(1,2), (1,3), (1,4),
    (2,3), (2,4), (2,5), (2, 6),
    (3,4), (3,5), (3,6), (3,7),
    (4,6), (4,7), (5,6), (6,7)]
g.add_edge(1,2),g.add_edge(1,3),g.add_edge(1,4),g.add_edge(2,3),
g.add_edge(2,4),g.add_edge(2,5),g.add_edge(2,6),g.add_edge(3,4),
g.add_edge(3,5),g.add_edge(3,6),g.add_edge(3,7),g.add_edge(4,6),
g.add_edge(4,7),g.add_edge(5,6),g.add_edge(6,7)
g.show()
g.adjacency_matrix(),g.incidence_matrix()

<nafecclcfhdoekfh.png>

Best

Reply all
Reply to author
Forward
0 new messages