Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSC 213 – Large Scale Programming. Today’s Goals  Discuss what is NOT meant by term “Graph”  Why no bar charts, scatter plots, & pie charts mentioned.

Similar presentations


Presentation on theme: "CSC 213 – Large Scale Programming. Today’s Goals  Discuss what is NOT meant by term “Graph”  Why no bar charts, scatter plots, & pie charts mentioned."— Presentation transcript:

1 CSC 213 – Large Scale Programming

2 Today’s Goals  Discuss what is NOT meant by term “Graph”  Why no bar charts, scatter plots, & pie charts mentioned  How term is used for mathematical graph  Review terminology of mathematical graphs  Why do we care about edges & vertices  Directed vs. undirected more than types of plays  Which 1 of these made up: incident, adjacent, feeder  Cycles & paths not related to Queen songs  Examine G RAPH ADT’s method & what they do

3 Graphs  Mathematically, graph is pair (V, E) where  V is collection of nodes, called vertices  Two nodes can be connected by an edge in E  Position implemented by Vertex & Edge classes ORD PVD MIA DFW SFO LAX LGA HNL 849 802 1387 1743 1843 1099 1120 1233 337 2555 142

4 Edge Types  Edge connects two vertices in the graph  Image we have edge connecting u & v  (u, v) is name given to this edge  Edges can be directed  One-way street is directed edge  u is origin or source  v is destination  Undirected edge is alternative  Vertices listed in any order  Subway lines normally undirected LifeDeath BestCanisius

5 Undirected Graph Applications  Electronic circuits  Transportation networks  Databases  Packing suitcases  Finding terrorists  Assigning classes to rooms  Coloring countries on a map  Playing minesweeper

6 Directed Graph Problems  Used to solve many problems in real-world  Not always obvious: directedness used in many ways  Examples:  Diagnose cause of injury  Schedule tasks to perform  Garbage collection  Track progress of disease  Compiling a program

7 Graph Types

8 Weighted Graphs  Edge’s weight is cost of using edge  Distance, cost, travel time, &c. usable as the weight  Weights below are distance in miles  Edges undirected; but directed weighted Graph legal ORD PVD MIA DFW SFO LAX LGA HNL 849 802 1387 1743 1843 1099 1120 1233 337 2555 142

9 Terminology incident  Edge incident on its endpoints  U & V endpoints of a adjacent  Vertices adjacent when joined by edge  U adjacent to V  V adjacent to U  Directedness unimportant  Directedness unimportant determining adjacency XU V W Z Y a c b e d f g h i j

10 Terminology  Degree  Degree of vertex is number incident edges  X has degree of 5  Does not matter if edges directed or not  What the edges’ other endvertices unimportant  (Self-edges only count once) XU V W Z Y a c b e d f g h i j

11 Path Terminology  Path  Path is set of vertices in Graph where  All of the consecutive vertices adjacent  May or may not have edge from last to first vertices ( U, W, X, Y, W, V ) is path XU V W Z Y a c b e f g h

12 Path Terminology  Simple path  Simple path is a path which:  Is named by alternating vertices & edges  0 or 1 appearance for each vertex & edge ( V, b, X, h, Z ) is simple path XU V W Z Y a c b e d f g h

13 Cycle Terminology  Cycle  Cycle is path with several additional properties  Each cycle must begin & end at same vertex  No edge required from this vertex to itself  Simple cycle  Simple cycle is special cycle  But is also simple path ( V, X, Y, W, U, V ) is simple cycle XU V W Z Y a c b e d f g h

14 Graph ADT  Accessor methods  vertices() : iterable for vertices  edges() : iterable for edges  endVertices(e) : array with end points of edge e  opposite(v,e) : e ’s end point that is not v  areAdjacent(v,w) : check if v and w are adjacent  replace(v,x) : make x new element at vertex v  replace(e,x) : make x new element at edge e  Update methods  insertVertex(x) : create vertex storing element x  insertEdge(v,w,x) : add edge (v,w) with element x  removeVertex(v) : remove v (& incident edges)  removeEdge(e) : remove e  Retrieval methods  incidentEdges(v) : get edges incident to v

15 For Next Lecture  No weekly assignment this week or next  Get cracking on coding up your program #2  Due on Wednesday, so better start working on it  How were designs & test? What could you do better?  Reading on implementing Graph for Friday  What are simplest implementations of Graph?  When would each be good to use is program?


Download ppt "CSC 213 – Large Scale Programming. Today’s Goals  Discuss what is NOT meant by term “Graph”  Why no bar charts, scatter plots, & pie charts mentioned."

Similar presentations


Ads by Google