CoCalc Public FilesGraphes.sagewsOpen with one click!
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 nn

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+1n+1 sommets :

  • X={0,1,,n}X=\{0,1,\ldots,n\}
  • A={{0,i}1in}{{i,i+1}1in1}{{n,1}}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 n1n\geq1 on définit le cube de dimension nn :

  • X={0,1}nX= \{0,1\}^n
  • A={{a1,,an},{b1,,bn}ai=bisauf pour exactement un indicei}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 nn sommets.

On a nn 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