Skip to content
Snippets Groups Projects
Commit a1f26453 authored by Nicolas Floquet's avatar Nicolas Floquet
Browse files

FLOQUET_NICOLAS_Graphe_v03_avec_test_graphe

parent 1e74f8c0
No related branches found
No related tags found
2 merge requests!12Floquet nicolas graphe v01,!9Floquet Nicolas graphe v01
CC= gcc
CXXFLAGS= -Wall --pedantic -O3
CPP_O_FILE = test-graphe.o
LIB = -lm
all: $(CPP_O_FILE)
$(CC) $(CXXFLAGS) -o test-graphe.exe test-graphe.c ../src/graphe.c $(LIB)
clean:
rm -rf *.o *.exe
#include <stdio.h>
#include <stdlib.h>
#include "../src/graphe.h"
#define NB_SOMMETS 7
int main()
{
graphe g;
creer_graphe(&g, NB_SOMMETS);
ajouter_arete(&g, 0, 1);
ajouter_arete(&g, 0, 9);
ajouter_arete(&g, 1, 3);
ajouter_arete(&g, 1, 2);
ajouter_arete(&g, 1, 4);
ajouter_arete(&g, 2, 4);
ajouter_arete(&g, 3, 4);
ajouter_arete(&g, 3, 5);
ajouter_arete(&g, 4, 5);
ajouter_arete(&g, 4, 6);
ajouter_arete(&g, 5, 6);
graphe_afficher(&g);
printf("Retirons le sommet 4 (un nouveau sommet 4 prendra sa place\n");
retirer_sommet(&g, 4);
printf("Retirons les arêtes 4-5, 1-3, et 5-4 (déjà retirée)\n");
supprimer_arete(&g, 4, 5);
graphe_afficher(&g);
supprimer_arete(&g, 1, 3);
graphe_afficher(&g);
supprimer_arete(&g, 5, 4);
graphe_afficher(&g);
graphe_detruire(&g);
return EXIT_SUCCESS;
}
from scipy import sparse
from numpy.random import rand
print("On crée une matrice creuse de taille 10x10, elle est initialement vide \nAffichons la")
A = sparse.lil_matrix((10, 10))
print(A)
print("Rien ne s'est passé, car j'ai affiché une matrice creuse vide\n\
Vide donc elle n'a que des 0\n\
Donc rien ne s'est affiché\n\
Pour rappel les 0 d'une matrice creuse ne sont pas stockés")
A[0, :5] = rand(5) #5 coefficients
print("Des colonnes 0 à 4 à la ligne 0, on a ajouté des valeurs au hasard")
print(A)
A[1, 5:7] = A[0, :2] #2 nouveaux
print("Des colonnes 5 à 7 à la ligne 1, on a ajouté des valeurs au hasard")
print(A)
A.setdiag(rand(10)) #9 autres
print("On ajoute des nouvelles valeurs sur toutes la diagonale avec la fonction setdiag")
print(A) # affichage type:'creux' 26 coefficients sur 100 non nuls
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment