Um grafo é ponderado quando suas arestas possuem um peso. O que significa isso? Bom… Vamos supor que eu queira ir de um lugar pra outro, mas o mais importante pra mim não seja a distância entre eles mas o pedágio que vou ter que pagar para pegar cada aresta (estrada). Nesse caso, o peso de cada aresta seria o custo que eu tenho pra passar pela estrada. O problema então seria calcular o caminho onde eu pago menos (o caminho que tem a menor soma de preços) e não o menor caminho no grafo “não-ponderado” (onde consideramos aresta=1 e nada=0).

Neste grafo, por exemplo, o menor caminho de 1 a 3 não é a aresta 1-3, mas sim a aresta 1-2 e depois a aresta 2-3.

Para representar um grafo ponderado usando a matriz de adjacência, onde antes marcávamos “1″, marcamos o peso que temos de ir de um vértice para o outro e onde marcávamos “0″ marcamos $$\infty{}$$ (infinito)*.

 1 2 3 4 1 $$\infty{}$$ 10 40 $$\infty{}$$ 2 10 $$\infty{}$$ 20 50 3 40 20 $$\infty{}$$ 20 4 $$\infty{}$$ 50 20 $$\infty{}$$

* Na verdade, só fazemos isso porque neste caso iríamos querer o menor caminho e o 0 poderia atrapalhar, porque poderíamos ter um caminho sem pedágio, por exemplo, mas isso sempre depende do caso.

Usando listas de adjacência, podemos representar as ligações de cada vértice com dois vetores (um para dizer a qual ele se liga e outro o peso desta ligação) ou com um vetor de structs como:

struct edge { int destino, peso; };

## 533 thoughts on “Grafos Ponderados”

1. - You've got a lot of nerve but you're running low on the analytical scale. That big chip on your shoulder seems to be blocking your field of view. I don't see anything in the post by Anonymous that asserts a religious point of view, nor do I see anything in my post that indicates passivity. Au contraire.

2. Magari volevano dire 11 mila migliaia di ore di volo (che sarebbe pure peggio…)Comunque il fatto che il primo pilota non fosse ai comandi non mi pare poi cosÃ¬ grave, non mi risulta che durante il volo di crociera si piloti "a mano"…il pilota automatico che ci sta a fare?

3. I’m also commenting to make you be aware of of the exceptional encounter my cousin’s girl gained studying your site. She learned several details, which included what it’s like to possess an awesome helping style to get other people very easily understand several advanced subject matter. You undoubtedly exceeded my desires. I appreciate you for presenting those productive, safe, educational and also cool thoughts on your topic to Sandra.

4. Co jÃ¡ vÃ­m TopolÃ¡nek jednal za trojkoalici – tedy zastupoval 100 hlasÅ¯ – a hledal podporu u ÄŒSSD. NevidÃ­m Å¾Ã¡dnÃ½ dÅ¯vod proÄ by se ÄŒSSD nedokÃ¡zala dohodnou s koalicÃ­ pokud se dokÃ¡Å¾e dohodnout s ODS (ostatnÃ­ dvÄ› strany majÃ­ k ÄŒSSD programovÄ› o trochu blÃ­Å¾).

5. especially special website…I’ve really recently been vanished just for some time, still presently around My own spouse in addition to i remember exactly the reason why Document which allows you to absolutely love this method website. Thank a person, I may effort determine spine…

6. I not to mention my pals have already been studying the good hints located on your web site and all of a sudden I had a terrible suspicion I never thanked the web site owner for those tips. Those young boys appeared to be as a consequence stimulated to read them and have now in actuality been having fun with those things. Thank you for turning out to be well thoughtful as well as for deciding on these kinds of beneficial information most people are really desperate to understand about. My honest regret for not saying thanks to sooner.

7. I not to mention my guys were checking out the great techniques found on the blog and so all of a sudden came up with a terrible feeling I never thanked the blog owner for those secrets. These people became so thrilled to see them and have in effect undoubtedly been tapping into these things. Thank you for really being very considerate and also for picking out some very good themes most people are really wanting to learn about. My very own sincere apologies for not saying thanks to you sooner.

8. A lot of thanks for all your efforts on this web page. My aunt take interest in participating in investigation and it’s obvious why. I notice all regarding the compelling medium you produce worthwhile tips and tricks through your web blog and even cause response from others on that subject so my princess is actually starting to learn a lot of things. Enjoy the rest of the new year. You’re carrying out a stunning job.

9. Posted on December 17, 2012 at 12:38 pmWhen required tolerances cannot be met on a daily basis! Problem: Very Shallow Penetration: Solution: Check Polarity + Hard Wire gas – Flux-Cored no gas Problem: Poor quality/discolored Welds: Solution: Make sure that you can run steel, aluminum, or stainless steel. The manufacturing industry employs most workers. {||||

10. A lot of thanks for all of your hard work on this site. My daughter really loves making time for investigations and it’s really obvious why. We learn all relating to the compelling means you provide helpful strategies via this website and as well improve participation from the others on this subject matter and our favorite child is actually discovering a whole lot. Enjoy the rest of the year. You are always carrying out a fabulous job.

11. I really wanted to make a small note to thank you for these amazing concepts you are sharing on this site. My time intensive internet look up has at the end been honored with useful facts to share with my guests. I would tell you that we site visitors actually are quite fortunate to live in a wonderful network with very many lovely people with very beneficial plans. I feel very much fortunate to have come across the website page and look forward to so many more exciting moments reading here. Thanks once again for all the details.

12. at Good Cheap Eats, describes how she makes homemade pintos and refried beans. She cooksÂ them herself and it proves to be much cheaper than fifty cents a

14. it was not good for the children to be introduced to another woman at this sensitive time (this was back in November). My therapist called him and he said no one was going to tell him what to do. I found out recently, that she has moved in with him, due to problems with her husband (duh)and he asked the children not to tell me, basically, encouraging them to lie. I have decided to get a lawyer and seek primary custody. How will his actions affect custody? My friend had it written in her agreement that there could be no overnight visitations from woman while the children were there – how can that be enforced?

15. you ignorant person, nicki minaj is the next greatest thing! did u hear the news? she’s the only female. artist to ever have so many Billboard Hot 100 entries in year. 11 entries in year. yeah so we are lucky that we DO know who she is- and for those who dont- look up her music, she really does have talent

16. My spouse and i have been so joyous when John managed to deal with his basic research using the ideas he acquired when using the blog. It is now and again perplexing to simply happen to be releasing helpful hints that many some people could have been selling. We discover we need the blog owner to be grateful to for that. The type of illustrations you have made, the simple web site navigation, the relationships you will make it possible to create – it is all exceptional, and it is leading our son and the family feel that that article is interesting, which is extremely fundamental. Many thanks for the whole thing!

17. I am only writing to let you understand what a remarkable discovery my princess undergone reading through the blog. She came to find some pieces, most notably what it’s like to have an ideal giving nature to have many others without problems grasp various impossible things. You truly did more than our expected results. Many thanks for displaying those great, safe, edifying and as well as easy tips about your topic to Tanya.

18. I wanted to post you this little note so as to give thanks the moment again about the stunning information you’ve shown at this time. This is certainly tremendously open-handed of you in giving unhampered what a lot of people could possibly have supplied for an ebook in order to make some dough for their own end, mostly given that you might have done it if you decided. These good tips additionally acted as a great way to realize that other individuals have similar desire much like my personal own to know a little more regarding this matter. Certainly there are thousands of more pleasant sessions up front for individuals that read carefully your site.

19. So fun! I love the pez dispenser collection in the first pic. If you need a bobo fett let me know!The painting of the streetcar looks just like the streetcars we have in Toronto – it’s not right?

20. op de vraag die gesteld wordt in het onderstaande commentaar. Lees mijn artikel op 1825 Dagen, BiblioLab: van transactie naar transformatie, en je weet het antwoord: Ja! Dit is de kant die fysieke bibliotheken (moeten)

21. OMG I need Candy shop. So so so pretty! I was thinking that the color reminded me of some type of candy and I scroll down and see it’s named Candy shop. PinkGlitter recently posted …

22. Thanks for your entire labor on this blog. My mom takes pleasure in working on internet research and it’s easy to see why. We all notice all relating to the dynamic way you convey both useful and interesting thoughts by means of the web blog and in addition attract participation from other ones about this concern and our favorite child has been discovering a lot. Take advantage of the remaining portion of the year. Your conducting a really good job.

23. - Awesome site Aaron! It’s no surprise what a fan I am of you and your sisters work, so I’m stoked for you both to be venturing into new chapters of your careers. Congrats and all happiness in the world.

24. I am just commenting to let you know what a impressive experience my friend’s daughter encountered browsing your blog. She came to understand lots of pieces, with the inclusion of what it’s like to have an awesome coaching style to get the mediocre ones smoothly fully understand certain tortuous subject matter. You actually did more than our desires. Many thanks for supplying these invaluable, dependable, revealing as well as easy tips about the topic to Sandra.

25. francesco p scrive:Purtroppo la forma Ã¨ in commercio… la sostanza Ã¨ di nicchia e quasi introvabile…la sostanza Ã¨ dei pensatori,io cerco di apprenderne un po’da quelli notturni, che trovi camminare di notte avanti e dietro, per quei 25 metri quadrati di bianco sporco, che Ã¨ diventato il paese…la sostanza Ã¨ come il vino buono, devi girare molto prima di trovare il contadino che fa fermentare il mosto da solo, senza additivi….Michele se il mio contadino di fiducia, se il mio aglianico d.o.c.g.ciao

26. I am just writing to make you understand of the fantastic experience our girl gained studying your blog. She learned some pieces, which included how it is like to have an ideal coaching mood to make the others very easily fully grasp selected tortuous matters. You actually surpassed readers’ desires. I appreciate you for showing those warm and helpful, trusted, informative and unique tips about this topic to Gloria.

27. em chao A/C, e da tot nghiep TCCN, thi jo e vao hoc co duoc mien hoc cac mon hoc nhu la chinh tri, phap luat, giao duc the chat..hay khong ah.?

28. Note to JWG:I totally agree with you on the “recent” leaks of scientific data from the Global Warming terrorists..erm, scientists. Mr. Gore definitely needs to return his Nobel Prize, refund movie tickets to those who went to see the travesty to science he called the “I.C.T.”, end this get-rich-quick “energy exchange” system, reduce his personal carbon imprint that is exponentially larger than any other US Citizen’s, & apologize to the world for misleading them with his version of “junk science”. IMO.

29. I am just writing to let you be aware of of the great experience my cousin’s princess obtained checking your webblog. She realized a good number of things, which include what it is like to possess an awesome giving style to let a number of people effortlessly grasp a number of specialized matters. You actually surpassed visitors’ desires. Thank you for supplying such informative, healthy, edifying not to mention cool tips on this topic to Gloria.

30. I would like to show thanks to you just for bailing me out of this scenario. As a result of scouting throughout the search engines and seeing techniques that were not beneficial, I was thinking my life was done. Being alive without the presence of solutions to the difficulties you’ve solved by means of your main article is a serious case, as well as the kind that would have negatively affected my career if I had not come across the blog. Your primary understanding and kindness in handling all areas was useful. I’m not sure what I would’ve done if I hadn’t come upon such a subject like this. I’m able to at this time relish my future. Thanks for your time so much for the professional and sensible guide. I will not think twice to propose your web blog to any person who should get support about this subject matter.

31. Thanks for all of your efforts on this site. My mother loves getting into internet research and it’s really easy to see why. Many of us learn all relating to the lively means you produce precious guides through your website and in addition boost participation from other individuals on that matter while my simple princess is discovering a lot of things. Enjoy the remaining portion of the year. You are always doing a pretty cool job.

32. Thank you so much for providing individuals with an extremely wonderful opportunity to check tips from here. It can be very awesome and as well , full of a good time for me and my office acquaintances to search your blog at the least three times per week to learn the fresh guidance you have. And definitely, I am just always pleased with your magnificent strategies you serve. Some 2 areas in this post are easily the very best we have all had.