grafuri orientate n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Grafuri orientate PowerPoint Presentation
Download Presentation
Grafuri orientate

Loading in 2 Seconds...

play fullscreen
1 / 11

Grafuri orientate - PowerPoint PPT Presentation


  • 488 Views
  • Uploaded on

Grafuri orientate. Proiect realizat de Caramizoiu Vlad Colegiul National Ecaterina Teodoriu. Aplicatii ale grafurilor in viata reala

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Grafuri orientate' - myron


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
grafuri orientate
Grafuri orientate

Proiectrealizat de CaramizoiuVlad

Colegiul National EcaterinaTeodoriu

slide2

Aplicatii ale grafurilor in viatareala

Sa presupunem ca esti in Targu-Jiu,esteora 7:45 sivreisaajung la scoalainainte de ora de incepere a cursurilor ,aceastafiindsituata in parteaopusa a orasului .Mai aila dispozitie 15 minute astfel ca singuratasansaestesagaseascidrumulcelmaiscurt.

slide3

Intr-un moment de sclipireacestaitidaiseama ca reteauastadala a orasului seaman cu un graforientatsi ca potiulitiza un program C++ pentru a determinadrumulminim.

Inainte de o continua povesteasa ne amintimcatecevadespregrafuri.

slide7

Asadartrebuiasarealizezi un algoritm care sacalculezedrumulcelmaiscurt de la tine de acasapana la scoala la care inveti.(Daca nu stiirealizezi un astfel de algoritmesteprobabil din cauza ca tejucai asphalt 8 in timpceprofesoaraexplicagrafurile)

Sa presupunem ca fiecarestarda(muchie) in functie de lungimieasa are un anumitcost.Unastfel de program consta in gasirealantului de cost minim ceunestecele 2 puncte .

Un grafcaruiais-a asociat o functie cost se numestegrafponderat.Functia cost asociataunaigraf se folosestepentrudeterminareadrumurilor de cost minim existenteintrecele 2 noduri ale graficului.Pentruaceastafiecaruigrafi se asociaza o matricenumitamatriceacosturilor.Matriceacosturilor are 2 variante in functie de scopul in care a fostdefinita.

slide8

Pentrudeterminareadrumurilor de cost minim

se definestematriceastfel:

-M(i,j)=0,daca i=j;

- M(i,j)=c(cost),dacai!=j siexista arc de la i la j ;

-M(i,j)=∞,dacai!=j sinu exista arc de i la j.

Pentrudeterminareacostului minim intre 2 noduri (x si y)se pleaca de la matriceainitiala M si se transformaaceastaasemanatoralgoritmului de obtinere al matriceidrumuriloralegandfiecare nod ca fiind nod intermediarintrealte 2 noduri

slide9

Matriceadrumurilor de cost minim se obtine cu algoritmulRoy-Floyd:

#include<fstream.h>

ifstreamf(“date.in”);

ofstreamg(“date.out”);

intmain()

{f>>n>>m;

for(i=1;i<=n;i++)

for(f=1;j<=n;j++)

if(i==j)

a[i][j]=0;

else

a[i][j]=9999999;

slide10

for(i=1;i<=n;i++)

{f>>x>>y>>c;

a[x][y]=c;}

for(k=1;k<=n;k++)

for(i=1;i<=n;i++)

for(j=1;j<=n;j++)

if(a[i][j]>a[i][k]+a[k][j])

a[i][j]=a[i][k]+a[k][j];

for(i=1;i<=n;i++)

{ for(j=1;j<=n;j++)

g<< a[i][j]<<’ ‘;

g<<’n’;}}

slide11

In final probabil nu veireusiisafaci un program functional ,veiintarzia la scoalaajungandastfel la 10 absente sidrepturmare media ta la purtarevaavea de suferit de suferit.

Morala:

Fiiatent la ora de informatica ,nu stiiniciodatacand o saititrebuiasca in viata.