CoCalc Public FilesGraphes.sagews
Author: Juan Carlos Bustamante
Views : 64
Compute Environment: Ubuntu 18.04 (Deprecated)

## Quelques exemples de graphes

typeset_mode(True)


### Un graphe au hasard, faut spécifier le nombre de sommets et d'arêtes.


g = graphs.RandomGNM(10, 15)  # 10 sommets and 15 arêtes
show(g)
g.incidence_matrix()

d3-based renderer not yet implemented
[1 1 1 1 0 0 0 0 0 0 0 0 0 0 0] [1 0 0 0 0 0 0 0 0 0 0 0 0 0 0] [0 1 0 0 1 1 0 0 0 0 0 0 0 0 0] [0 0 1 0 0 0 1 1 1 0 0 0 0 0 0] [0 0 0 0 0 0 1 0 0 1 0 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 1 0 0 0 0] [0 0 0 0 0 0 0 0 0 0 1 1 1 1 0] [0 0 0 0 1 0 0 0 0 0 0 1 0 0 1] [0 0 0 1 0 1 0 1 0 0 0 0 1 0 1] [0 0 0 0 0 0 0 0 1 1 0 0 0 1 0]

### La chaîne de longueur $n$

X = [[k, k+1] for k in range(4)]
g = Graph(X)
show(g)

d3-based renderer not yet implemented
G=Graph([["A","G"],["A","E"],["A","B"],["B","H"],["B","F"],["H","G"],["E","F"],["G","I"],["H","J"],["F","L"],["E","K"],["I","K"],["I","J"],["J","L"],["L","K"]])
G.show(layout="planar")


︠d74b4bed-fdfa-4922-bb7e-a412b80f85c3︠

︠d7ea2f5b-a3ea-456b-8a2f-037e02a15b70i︠
%md
### La roue à $n+1$ sommets :
- $X=\{0,1,\ldots,n\}$
- $A = \{\{0,i\}| 1\leq i \leq n \} \cup \{ \{i,i+1\}| 1\leq i\leq n-1 \} \cup \{\{n,1\}\}$


### La roue à $n+1$ sommets :

• $X=\{0,1,\ldots,n\}$
• $A = \{\{0,i\}| 1\leq i \leq n \} \cup \{ \{i,i+1\}| 1\leq i\leq n-1 \} \cup \{\{n,1\}\}$
n=8
A1= [[0, k+1] for k in range(n)]
A2 = [[k, k+1] for k in range(1,n)]
A = A1+A2 + [[1,n]]
g=Graph(A)
show(g)


d3-based renderer not yet implemented

### Les cubes

pour $n\geq1$ on définit le cube de dimension $n$ :

• $X= \{0,1\}^n$
• $A = \{\{a_1,\ldots,a_n\},\{b_1,\ldots,b_n\}| a_i = b_i \text{sauf pour exactement un indice} i \}$
n=4
g=graphs.CubeGraph(n)
show(g)

d3-based renderer not yet implemented

︠fd438da6-c670-4d9b-9b1c-dad161073b7c︠

︠fdb9260f-46b0-460d-9d02-8d8cbbbe97b1i︠
%md
### Les graphes complets sur $n$ sommets.
On a $n$ sommets, et toutes les arêtes possibles.



### Les graphes complets sur $n$ sommets.

On a $n$ sommets, et toutes les arêtes possibles.

K = graphs.CompleteGraph(21)
show(K)

d3-based renderer not yet implemented

︠559e391a-b440-4c3a-8447-45389c7fe420︠
︠aa068128-7956-4dc2-937c-a22cd734a859︠