CS Lunch Interested in graduate school in CS? Wednesday, 12:20 to - - PowerPoint PPT Presentation

cs lunch
SMART_READER_LITE
LIVE PREVIEW

CS Lunch Interested in graduate school in CS? Wednesday, 12:20 to - - PowerPoint PPT Presentation

1 CS Lunch Interested in graduate school in CS? Wednesday, 12:20 to 1:20 Jaemarie Solyst Emilyann Nault Ammal Abbasi Ana Berthel Also, a presentation about the Master s in Cyber Security at WPI 2 Party Problem You want to


slide-1
SLIDE 1

CS Lunch

Interested in graduate school in CS? Wednesday, 12:20 to 1:20 Jaemarie Solyst
 Emilyann Nault
 Ammal Abbasi
 Ana Berthel Also, a presentation about the Master’ s in 
 Cyber Security at WPI

1

Party Problem

You want to throw a party at which there are no pairs of guests that do not get along. You want to invite as many guests as possible. How would you solve this?

2

The party problem

Represent each guest as a node Draw an edge between guests who do not get along Find the largest set of nodes where there is no edge between any pair of nodes in the set

Alice Greta Freida Eunice Dorothy Cheryl Brenda

3 Slides07 - Directed graphs.key - February 13, 2019

slide-2
SLIDE 2

Bipartite Graphs

A bipartite graph is an undirected graph G = (V, E) in which the nodes can be colored red or blue such that every edge has one red and one blue end.

is a bipartite graph is NOT a bipartite graph

4

A bipartite solution

Alice Greta Freida Eunice Dorothy Cheryl Brenda

5

A bipartite solution

Alice Greta Freida Eunice Dorothy Cheryl Brenda

6 Slides07 - Directed graphs.key - February 13, 2019

slide-3
SLIDE 3

A bipartite solution

Alice Greta Freida Eunice Dorothy Cheryl Brenda

7

A bipartite solution

Alice Greta Freida Eunice Dorothy Cheryl Brenda

8

A bipartite solution

Alice Greta Freida Eunice Dorothy Cheryl Brenda

9 Slides07 - Directed graphs.key - February 13, 2019

slide-4
SLIDE 4

A bipartite solution

Alice Greta Freida Eunice Dorothy Cheryl Brenda

10

A bipartite solution

Alice Greta Freida Eunice Dorothy Cheryl Brenda

11

A bipartite solution

Alice Greta Freida Eunice Dorothy Cheryl Brenda

Who should you invite?

12 Slides07 - Directed graphs.key - February 13, 2019

slide-5
SLIDE 5

Layer 1 Layer 2 Layer 3 Layer 4 Layer 0

BFS and Bipartite Graphs

  • Lemma. Let G be a connected graph, and let L0, …, Lk be the

layers produced by BFS starting at node s. Exactly one of the following holds. (i) No edge of G joins two nodes of the same layer, and G is bipartite. (ii) An edge of G joins two nodes of the same layer, and G contains an odd-length cycle (and hence is not bipartite).

Alice Greta Freida Eunice Dorothy Cheryl Brenda

13

BFS and Bipartite Graphs

Layer 1 Layer 2 Layer 3 Layer 4 Layer 0

  • Lemma. Let G be a connected graph, and let L0, …, Lk be the

layers produced by BFS starting at node s. Exactly one of the following holds. (i) No edge of G joins two nodes of the same layer, and G is bipartite. (ii) An edge of G joins two nodes of the same layer, and G contains an odd-length cycle (and hence is not bipartite).

Alice Greta Freida Eunice Dorothy Cheryl Brenda

14

Directed Graphs

1 3 5 4 2

Directed graph. G = (V, E) Edge (u, v) goes from node u to node v. Example: Web graph - hyperlink points from one web page to another. Directedness of graph is crucial. Modern web search engines exploit hyperlink structure to rank web pages by importance. 1 2 3 4 5 1 0 1 0 1 1 2 0 0 1 1 3 0 0 0 0 0 4 0 0 0 0 0 5 0 0 1 0 0

15 Slides07 - Directed graphs.key - February 13, 2019

slide-6
SLIDE 6

Adjacency List

Store the edges in the list in the direction that the edge points

1 3 5 4 2

1 2 3 4 5 2 4 5 3 4 3

TO

16

Finding Paths

Use BFS or DFS No guarantee that there is a reverse path

1 3 5 4 2

1 2 3 4 5 2 4 5 3 4 3

TO

17

Strong Connectivity

Node u and v are mutually reachable if there is a path from u to v and also a path from v to u. A graph is strongly connected if every pair of nodes is mutually reachable.

1 3 5 4 2

is NOT strongly connected.

1 3 5 4 2

is strongly connected.

18 Slides07 - Directed graphs.key - February 13, 2019

slide-7
SLIDE 7

Strong Connectivity

  • Lemma. Let s be any node. G is strongly connected

iff every node is reachable from s, and s is reachable from every node. Proof?

19

Directed Acyclic Graphs

A directed acyclic graph (DAG) is a directed graph that contains no directed cycles.

1 3 5 4 2

is a DAG

1 3 5 4 2

is NOT a DAG

20

Directed Acyclic Graphs

Uses for DAGs: Derives-from: You must buy food in order to make dinner. Timing: You should finish your homework before it is due. Is-bigger-than, is-faster-than, ... Any relationship that imposes a partial order.

21 Slides07 - Directed graphs.key - February 13, 2019

slide-8
SLIDE 8

Topological Order

A topological order of a directed graph G = (V, E) is an

  • rdering of its nodes as v1, v2, …, vn so that for every

edge (vi, vj) we have i < j

1 3 5 4 2 1 3 5 4 2

DAG DAG’ s Topological Ordering

22

Computing the Topological Order

  • Lemma. If G is a DAG, then G has a node with no

incoming edges.

1 3 5 4 2

Proof?

23

Algorithm

topological-order(v) { find a node v with no incoming edges delete v from G return v followed by topological-order (G - {v}) }

1 3 5 4 2

24-1 Slides07 - Directed graphs.key - February 13, 2019

slide-9
SLIDE 9

Algorithm

topological-order(v) { find a node v with no incoming edges delete v from G return v followed by topological-order (G - {v}) }

1 3 5 4 2 3 5 4 2

Step 1

24-2

Algorithm

topological-order(v) { find a node v with no incoming edges delete v from G return v followed by topological-order (G - {v}) }

1 3 5 4 2 3 5 4 2

Step 1

3 4 2 Step 2

24-3

Algorithm

topological-order(v) { find a node v with no incoming edges delete v from G return v followed by topological-order (G - {v}) }

1 3 5 4 2 3 5 4 2

Step 1

3 4 2 Step 2 3 4

Step 3

24-4 Slides07 - Directed graphs.key - February 13, 2019

slide-10
SLIDE 10

Algorithm

topological-order(v) { find a node v with no incoming edges delete v from G return v followed by topological-order (G - {v}) }

1 3 5 4 2 3 5 4 2

Step 1

3 4 2 Step 2 3 4

Step 3

3

Step 4

24-5

Algorithm

topological-order(v) { find a node v with no incoming edges delete v from G return v followed by topological-order (G - {v}) }

1 3 5 4 2

Order: 1, 5, 2, 4, 3

3 5 4 2

Step 1

3 4 2 Step 2 3 4

Step 3

3

Step 4

24-6 Slides07 - Directed graphs.key - February 13, 2019