160 likes | 181 Views
Explore the concept of graphs, graph notation, Euler circuits, and minimum spanning trees with a focus on Leonhard Euler's famous bridge problem in Königsberg. Learn about directed and undirected graphs, walks, trails, circuits, and weighted graphs. Discover Prim's algorithm for finding the minimum spanning tree in a graph.
E N D
Graphs April 20, 2009
Graph • A “graph” is a collection of “nodes” that are connected to each other • Graph Theory: This novel way of solving problems was invented by a Swiss mathematician, Leonhard Euler
Königsberg Bridge Problem • Euler was considering the layout of the bridges in the city Königsberg. The city was unusual in that it was built on an island in the river Pregel • The problem Euler was considering was to determine if it was possible for one to walk over all seven bridges exactly once and end up exactly where one started.
a b c d Graph of Bridges of Königsberg
Graph Notation • A graph is a set of nodes or vertices V that are joined by a set of edges E. V = {A,B,C} E={e1, e2, e3} Graph G = (V,E) A e1 C e2 B e3
Directed and Undirected Graphs • A graph is called a directed graph if the edge from vertex v1 to vertex v2 can only be traveled in that specific direction, and not in the reverse direction. • Directed edges are represented as an ordered pair (v1, v2)
Directed Graph Vertex Set V = {u, r,w} Edge Set E = {(r, u), (u, r), (w, r), (u, w)}
Complete Graph • A graph in which every vertex is connected by an edge to every other vertex • A complete graph on n vertices has n vertices and n(n − 1) / 2 edges
a d f c b e • How many vertices are there? • How many edges are there? • Is this a directed or undirected graph? • Is this a complete graph? • What are the set of vertices V and the set of edges E?
Walks, Trails, and Circuits • A walk is any sequence of vertices and edges starting at some vertex v0 and ending at a vertex vn. • A trailis a walk in which no edge is traversed more than once. • A circuitis a walk that begins and ends at the same vertex. • A graph is connectedif there is a walk from any vertex v1 to any other vertex v2.
Euler Circuits • Euler trailis a trail that includes every vertex in the graph. • An Euler circuit is an Euler trail that begins and ends at the same vertex. If any vertex in a graph is of odd degree (odd number of edges), the graph does not have an Euler circuit.
Weighted Graphs Philadelphia 127 82 266 Washington DC New York 209 392 220 Boston
Spanning Tree • A spanning tree is a special kind of subgraph of graph G that includes all the vertices that are in G (not necessarily all the edges) and in which there are no cycles or loops possible.
Minimum Spanning Tree (MST) • A spanning tree that has the least weight of all the spanning trees of G. Prim's Algorithm for the Minimum Spanning Tree • Write all the edges in the graph in order from smallest to biggest weight. • Working from smallest to biggest, add each edge into the MST only if it does not make a cycle. Stop when all the vertices are in the graph and the graph is connected (there are no isolated vertices).