0% found this document useful (0 votes)
36 views23 pages

DFS - BFS (Graphs) Luis Alberto Vásquez Vargas - : Peluchin

This document discusses graphs and some key graph concepts like vertices, edges, connected components, trees, and forests. It provides examples of how graphs can be used to represent relationships between people or connections between rooms in a house. It also defines some graph terminology like directed vs undirected edges, weighted vs unweighted graphs, and planar graphs.

Uploaded by

Marco Quintana
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views23 pages

DFS - BFS (Graphs) Luis Alberto Vásquez Vargas - : Peluchin

This document discusses graphs and some key graph concepts like vertices, edges, connected components, trees, and forests. It provides examples of how graphs can be used to represent relationships between people or connections between rooms in a house. It also defines some graph terminology like directed vs undirected edges, weighted vs unweighted graphs, and planar graphs.

Uploaded by

Marco Quintana
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

DFS BFS ( Graphs ) Luis Alberto Vsquez Vargas - Peluchin

Ahora tenemos N amigos, pero tengo solamente los

nmeros de telfono de algunos de ellos Quiero enviar un mensaje a Sarah llamando repetidas veces Mi memoria es tan bueno que me acuerdo que puedo contactar a mis amigos N Dame un plan de llamadas para m y para mis amigos

This is actually a graph!

Ryan Gary Joyce John

Winnie

Ada

Sarah

A set of vertices (or nodes) linked by edges

1 2 4

3 5

Mathematically, we often write G = (V,E)


V: set of vertices, so |V| = number of vertices E: set of edges, so |E| = number of edges

To present the relationships between different

objects/elements in a mathematical way Examples:


Friendship Local Area Network (LAN) Map of a country

What could the vertices and edges represent in the

above examples?

Living Room

Den

Bedroom

Kitchen

Hallway

Bath

The vertices could represent rooms in a house, and the edges could indicate which of those rooms are connected to each other. Sometimes a using a graph will be an easy simplification for a problem.

Living Room

Den

Hall
Bed Kitchen Bath

Apartment Blueprint

Scarecrow

Dorothy

Auntie M.

Tin Man

Cowardly Lion

The Wicked Witch of the West

Each vertex represents a person, and each edge indicates that the two people are friends.

Connected/disconnected graphs

The circled subgraphs are also known as connected

components

Directed/undirected graphs

You may treat each undirected edge as two directed

edges in opposite directions

Weighted/unweighted graphs
5 0
-2 7 4

You may treat unweighted edges to be weighted edges

of equal weights

Planar graphs
A graph that can be drawn on a plane without edge

intersections The following two graphs are equivalent and planar:

Tree

NO!

Tree: either one of the followings is the definition


A connected graph with |V|-1 edges
A connected graph without cycles A graph with exactly one path between every pair of

vertices

Tree edges could be directed or undirected

For trees with directed edges, a root usually exists

Forest
All connected component(s) is/are tree(s)

How many trees are there in the following forest?

Usually, the vertices are labeled beforehand

1
0 -2 7 4

2 types of graph representations:


Adjacency matrix Adjacency list

You might also like