Unformatted text preview:

Data Structures - GraphData Structures - GraphSlide 3Graph ProblemsExample Graph Problem - PuzzleSlide 6Example Graph Problem - Puzzle SolvedSlide 8Graph Problems - Traveling SalesmanGraph Problems - Graph ColoringGraph Problems - Maximum FlowCost of Graph ProblemsData Structures - TreeSlide 14Data Structures - HeapSlide 16Data Structures - Graph •Graphs are simply a collection of nodes (points) and edges connecting the nodes.•Typical notation lookslike this G = { N, E }. –G = the graph.–N = node set –E = edge set •Nodes represent items under consideration - can be anything.•Edges represent relationships between the items - can be anything.–Edges can be undirected, meaning the relationship holds both ways between nodes. –Edges can be directed, meaning the relationship is only one way.Data Structures - GraphName GraphDefinition A set of nodes (data elements) connected by edges in an arbitrary manner.Std Functions NoneNon-Std FunctionsNoneNotesThe most versatile data structure (linked lists, trees and heaps are special instances of graphs).Standard Problems:Graph Coloring: Coloring the nodes of a graph such that adjacent nodes do not have the same color.Traveling Salesman: Visiting each node in the graph exactly once for the least cost (start and stop at the same node).Maximum Flow: Determine the amount of flow through a network.Data Structures - GraphTHESE ARE ALL GRAPHS.Graph Problems•There are literally thousands of graph problems, but we will focus on three that are occur very commonly and show the diversity of the graph structure:–The Traveling Salesman Problem.–Graph Coloring Problem.–Maximum Flow Problem.•At least one of these problems is solved by you every day without you realizing it (until now).• The fact that the nodes and edges can represent anything means that the graph structure is very versatile and virtually any problem can be mapped to a graph problem.Example Graph Problem - Puzzle•This is an old puzzle and has many variants: A man is returning home from market with a wolf, bag of corn, and goose. He has to cross a lttle river on the way and the only way is to use a little boat. The boats holds him and one other item. –He cannot leave the wolf and goose alone, as the wolf eats the goose.–He cannot leave the corn and goose alone as the goose eats the corn.–He can leave the corn and wolf alone.•How does he get everything across the river and bring everything home (uneaten)?•Build a graph:–N = the set of possible arrangements of man, wolf, goose, corn, and river.–E = Possible transitions due to one boat trip.Example Graph Problem - Puzzlemwgc| mwg|c mwc| gmgc| wmc| wgmg| wcmw|gc wgc| mwg|mc wc| mggc| mwc| mwgg| mwcw|mgc m| wgc | mwgcExample Graph Problem - Puzzle Solvedmwgc| mwg|c mwc| gmgc| wmc| wgmg| wcmw|gc wgc| mwg|mc wc| mggc| mwc| mwgg| mwcw|mgc m| wgc | mwgcGraph Problems•There are literally thousands of graph problems, but we will focus on three that are occur very commonly and show the diversity of the graph structure:–The Traveling Salesman Problem.–Graph Coloring Problem.–Maximum Flow Problem.•Each problem has a decision form and an optimization form. The decision form asks "Can we do it?" and the optimization form asks "How well can we do it?"•At least one of these problems is solved by you every day without you realizing it (until now).• The fact that the nodes and edges can represent anything means that the graph structure is very versatile and virtually any problem can be mapped to a graph problem.Graph Problems - Traveling Salesman•Description: Given a graph, G = {N, E}, where–N = a set of cities.–E = travel routes between the cities, each having a cost associated with it.–One special node, s.–You must begin at city sand travel to each of the other cities exactly once and then return to city s. Thus you make a complete cycle of all cities in the graph. •Decision form of the problem: Can a route be found where the total cost of the trip is less than X? (Answer is yes or no).•Optimization form of the problem: What is the absolute lowest cost?Graph Problems - Graph Coloring•Description: Given a graph, G = {N, E}, where–N = a set of nodes.–E = edges between the nodes.–The object is to color the graph such that no nodes connecte by an edge have the same color. •Decision form of the problem: Can the graph be colored with X or less colors? (Answer is yes or no).•Optimization form of the problem: What is the fewest number of colors required to color the graph?Graph Problems - Maximum Flow•Description: Given a graph, G = {N, E}, where–N = a set of nodes.–E = edges representing pipes, each assigned a given capacity.–Two special nodes. Node s is a source node that can potentially spit out an infinite amount of material. Node f is a sink node that can potentially absorb an infinite amount of material.–The object is to determine the maximum amount of material that can flow through the network for the source to the sink.•Decision form of the problem: Can X amount of material be pushed through the network from the source to the sink? (Answer is yes or no).•Optimization form of the problem: What is the maximum amount of material that can flow through the material from the source to the sink?Cost of Graph ProblemsName Description Cost * CommentsTraveling Salesman DecisionDoes a route exist with cost less than X?O(n!) Hard to solve, easy to verify.Traveling Salesman OptimizationWhat is the least cost route.O(n!) Hard to solve, hard to verify.Graph ColoringDecisionCan a graph be colored properly using X colors?O(n!) Hard to solve, easy to verify.Graph Coloring OptimizationWhat is the least number of colrs required to properly color a graph?O(n!) Hard to solve, hard to verify.Maximum Flow What is the most material that can be pushed through a network? O(n3) Polynomial solution time means easy to solve, easy to verify.Data Structures - TreeName TreeDefinition A graph with directed edges connecting parent to child such that there is exactly one node with no parents and all other nodes have exactly one parent.Std Functions NoneNon-Std FunctionsNoneNotesThe first element in the tree is the “root” node, which has no parents, and from which all others can be reached.Nodes with no children are "leaf" nodes.If nodes “a” and “b” are connected by an edge, then: “a” is a child of “b” if “b” is closer to the root than “a”. “a”


View Full Document

UCF COP 2500C - Data Structures - Graph

Download Data Structures - Graph
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Data Structures - Graph and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Data Structures - Graph 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?