Grafos Ponderados

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).

Grafo Ponderado

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 [tex]\infty{}[/tex] (infinito)*.

  1 2 3 4
1 [tex]\infty{}[/tex] 10 40 [tex]\infty{}[/tex]
2 10 [tex]\infty{}[/tex] 20 50
3 40 20 [tex]\infty{}[/tex] 20
4 [tex]\infty{}[/tex] 50 20 [tex]\infty{}[/tex]

* 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. Bonjour,Merci pour votre post. Effectivement, la baisse du seuil à 0,6 v/m n’est pas encore adopté. Des pétitions et des courriers ont circulé sur internet pour alerter les pouvoirs publics. Il faut espérer que cela fonctionnera. Vous pouvez atteindre le seuil de 0,6 v/m avec notre étui (voir l’article sur l’émission c’est au programme).Pour la protection des enfants et adolescents, nous espérons que le plus de parents possibles sont informés. A quand des informations de bonne utilisation du portable dans les publicités ?

  13. 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?

  14. 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

  15. 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!

  16. 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.

  17. 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.

  18. 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.

  19. 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.

  20. 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

  21. 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.

  22. 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.

  23. 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.

  24. 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.

  25. 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.

  26. 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.

  27. I want to express thanks to the writer just for bailing me out of this type of issue. After exploring throughout the search engines and obtaining opinions that were not helpful, I believed my life was done. Being alive minus the answers to the issues you have resolved by means of this review is a critical case, as well as the kind which might have adversely affected my career if I hadn’t come across your website. Your own personal knowledge and kindness in dealing with all the stuff was very helpful. I don’t know what I would have done if I had not come upon such a solution like this. I am able to at this moment look ahead to my future. Thanks a lot so much for your skilled and amazing guide. I won’t think twice to endorse your blog to anybody who would need support on this subject.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>