Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Try ?Graph and/or ?DiGraph to get the documentation and examples of these "constructors".

The following dialog with the sage interpreter was leading to a directed graph D and an undirected one, G.

sage: M = matrix(6,6)
sage: for j,k in [(1,2),(2,3),(3,4),(3,5),(2,5),(5,6)]:
....:     M[j-1,k-1] = 1
....:         
sage: M
[0 1 0 0 0 0]
[0 0 1 0 1 0]
[0 0 0 1 1 0]
[0 0 0 0 0 0]
[0 0 0 0 0 1]
[0 0 0 0 0 0]
sage: D = DiGraph(M, format='adjacency_matrix')
sage: D.show()
Launched png viewer for Graphics object consisting of 13 graphics primitives
sage: G = Graph(M, format='adjacency_matrix')
sage: G.show()
Launched png viewer for Graphics object consisting of 13 graphics primitives
sage:

Possible link, one among many:

http://doc.sagemath.org/html/en/reference/graphs/sage/graphs/graph.html